☕ Java Beginner

What does the final keyword do in Java?

Why Interviewers Ask This

This is a classic screening question for Java roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

The final keyword has different meanings depending on where it is used. A final variable can be assigned only once — it is a constant. If it is a primitive, the value cannot change; if it is a reference, the reference cannot be reassigned (though the object's state can still change). A final method cannot be overridden by subclasses. A final class cannot be subclassed — for example, String, Integer, and Math are all final. Making a class final prevents inheritance and can be used for security or design reasons when the class's behavior must not be altered.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Java answers easy to follow.