What is an enum in Java?
An enum represents a fixed set of named values, such as PENDING, PAID and CANCELLED. It can also define fields and methods.
What is the difference between final and immutable in Java?
A final reference cannot be reassigned after initialization. The object it points to can still change unless its design prevents mutation.
What is a Java Stream used for?
It lets you process elements through steps such as filter, map and collect. A terminal operation triggers the processing.
What does Bean Validation check in a Spring API?
It applies declared constraints to input, such as a required name or a minimum quantity. Add separate checks for business rules such as available stock.
What is a Spring profile used for?
Profiles let you select configuration or beans for different environments. For example, tests can use an isolated database configuration.
What is optimistic locking in JPA?
It detects conflicting updates, commonly using a version field. If another transaction changes the record first, the stale update can fail instead of overwriting it.
What is the purpose of a database index in a Java app?
It can speed up lookups and sorting on appropriate columns. It also consumes storage and adds work when data changes, so measure the queries it should help.
How should a Java API handle an unexpected error?
Return a generic server error to the client and record technical details in server logs. Keep stack traces and secrets out of the response.
Explore related topics in the ScholarLogic project Q&A guide.