Can you change the value of a final variable in Java?
No. Once a final variable is assigned a value, it cannot be reassigned.
What does the final keyword mean for variables?
It means the variable can be assigned only once.
When can a final variable be assigned?
Either at declaration or once inside a constructor or initializer block.
Can a final variable remain uninitialized?
Yes, but it must be assigned exactly once before use.
What happens if you try to reassign a final variable?
The compiler throws an error.
Does final make objects immutable?
No. final prevents reference reassignment, not internal state changes.
Example of final reference behavior?
final List list = new ArrayList(); list.add(“A”); is allowed.
Can primitive final variables change value?
No. Primitive values cannot change once assigned.
Can instance final variables be assigned in constructor?
Yes. They can be initialized in constructors.
Can static final variables be assigned later?
They must be assigned at declaration or in a static block.
Why use final variables?
To create constants and prevent accidental modification.
Can final variables be overridden?
No. Variables cannot be overridden.
Does final improve performance?
Sometimes, because constants may be optimized by compiler.
What is a blank final variable?
A final variable declared without initialization but assigned later exactly once.
Key rule to remember?
final variable = assign once only.
Can a class be declared final in Java?
Yes. A class can be marked final to prevent it from being extended.
What does the final keyword mean for a class?
It means no other class can inherit from it.
Why would you make a class final?
To prevent modification through inheritance and ensure security or design integrity.
Example of a final class in Java API?
java.lang.String is final.
Can a final class have methods?
Yes. It can have any methods, but none can be overridden through inheritance.
Can a final class be abstract?
No. abstract requires inheritance, while final forbids it.
Can a final class be instantiated?
Yes. Final only prevents inheritance, not object creation.
What happens if you try to extend a final class?
The compiler throws an error.
Can a final class contain final methods?
Yes. Methods inside a final class can also be marked final.