Java Keywords – ALL Questions Answered (Strict
XM Style)
A. this Keyword
Very Short Questions
1. What is the this keyword?
Definition: The this keyword is a reference variable in Java that refers to the current object of a
class.
2. Why is the this keyword used?
Answer: It is used to identify the current object and to remove ambiguity between instance variables
and local variables.
3. Can this be used inside a static method?
Answer: No. Static methods belong to the class, not to any object, so this cannot be used.
4. Does this refer to the current object or class?
Answer: The this keyword always refers to the current object, not the class.
5. Can this be used to call another constructor?
Answer: Yes. The this() statement is used to call another constructor of the same class.
Short Questions
6. Explain the uses of this keyword.
Answer: The uses of the this keyword are: (i) to access instance variables, (ii) to call current class
methods, (iii) to call another constructor using this(), and (iv) to pass the current object as a
parameter.
7. Differentiate between local and instance variables using this.
Answer: When local and instance variables have the same name, the this keyword is used to refer
to the instance variable, thus removing ambiguity.
8. How does this help in constructor overloading?
Answer: In constructor overloading, this() allows one constructor to call another, reducing code
duplication.
9. Explain constructor chaining using this.
Answer: Constructor chaining is the process of calling one constructor from another constructor of
the same class using this().
10. State the rule of this().
Answer: The this() call must be the first statement inside a constructor.
Long Questions
11. Explain all uses of the this keyword.
Answer: The this keyword is used to refer to the current object, access instance variables, invoke
methods of the current class, call constructors, and pass the current object as an argument.
12. What happens if this() is not the first statement?
Answer: If this() is not the first statement in a constructor, the compiler generates a compile-time
error.
B. super Keyword
Very Short Questions
1. What is the super keyword?
Definition: The super keyword is a reference variable that refers to the immediate parent class
object.
2. What does super refer to?
Answer: It refers to the parent class object.
3. Can super access private members of a parent class?
Answer: No. Private members are not inherited, so they cannot be accessed using super.
4. Can super() and this() be used together?
Answer: No. Both must be the first statement in a constructor, so they cannot be used together.
5. Is super compulsory in inheritance?
Answer: No. If not written explicitly, the compiler automatically inserts it.
Short Questions
6. Explain the uses of the super keyword.
Answer: The super keyword is used to access parent class variables, call parent class methods,
and invoke the parent class constructor.
7. Differentiate between this and super.
Answer: this refers to the current class object, while super refers to the parent class object.
8. How does super help in method overriding?
Answer: In method overriding, super is used to call the parent class method from the subclass.
9. Explain constructor calling using super.
Answer: The super() statement is used to call the constructor of the parent class.
10. What happens if super() is not written?
Answer: The compiler automatically inserts a default call to the parent class constructor.
Long Questions
11. Explain all uses of the super keyword.
Answer: The super keyword accesses parent variables, invokes parent methods, and calls parent
constructors.
12. Explain method overriding using super.
Answer: In overridden methods, super is used to access the original implementation of the parent
class method.
C. Static vs Instance Variables
Very Short Questions
1. What is a static variable?
Answer: A static variable is a class-level variable shared by all objects.
2. What is an instance variable?
Answer: An instance variable is an object-level variable.
3. How many copies of a static variable exist?
Answer: Only one copy exists.
4. Can static variables be accessed without object?
Answer: Yes, by using the class name.
5. Where are instance variables stored?
Answer: Instance variables are stored in heap memory.
Short Questions
6. Write the difference between static and instance variables.
Answer: Static variables belong to the class, while instance variables belong to objects.
7. Explain memory allocation of static and instance variables.
Answer: Static variables are created once when the class is loaded; instance variables are created
for each object.
8. Why are static variables called class variables?
Answer: Because they are associated with the class rather than objects.
9. Can static variables access instance variables?
Answer: No, because instance variables require object creation.
10. What happens if a static variable is modified?
Answer: The change is reflected for all objects.
Long Questions
11. Explain the lifecycle of static and instance variables.
Answer: Static variables exist until the program ends, while instance variables exist as long as the
object exists.
12. When should static variables be used?
Answer: Static variables should be used when data needs to be shared among all objects.
Static Variable Instance Variable
Belongs to class Belongs to object
Single copy Multiple copies
Accessed using class name Accessed using object
Stored in method area Stored in heap memory
D. final Keyword
Very Short Questions
1. What is the final keyword?
Answer: The final keyword is used to restrict modification.
2. Can a final variable be changed?
Answer: No, it cannot be changed.
3. Can a final method be overridden?
Answer: No, final methods cannot be overridden.
4. Can a constructor be final?
Answer: No, constructors cannot be final.
5. Can a static variable be final?
Answer: Yes, static variables can be final.
Short Questions
6. Explain the final keyword.
Answer: The final keyword is used to restrict variables, methods, and classes from modification.
7. Difference between final and normal variable.
Answer: A final variable cannot be reassigned, while a normal variable can be reassigned.
8. Why final methods cannot be overridden?
Answer: To ensure consistent behavior and maintain security.
9. What happens if a final variable is not initialized?
Answer: A compile-time error occurs.
10. State the purpose of the final keyword.
Answer: It is used for security, immutability, and controlling inheritance.
Long Questions
11. Explain the final keyword in detail.
Answer: The final keyword prevents variable reassignment, method overriding, and class
inheritance.
12. Compare final, finally, and finalize.
Answer: final is a keyword, finally is a block in exception handling, and finalize is a method called
by JVM.
13. Explain the role of final in inheritance.
Answer: The final keyword prevents method overriding and class inheritance, ensuring controlled
design.