← Back to libraryQuestion 22 of 273
JavaBeginner

Keywords: this and super

📖 Detailed Explanation:

'this' refers to the current object instance. It is used to differentiate instance variables from parameters (shadowing), call other constructors, or pass the current object as an argument. 'super' refers to the parent class. It is used to call parent methods, access parent variables, or invoke parent class constructors.

🌍 Real-World Example:

this: 'I am speaking.' super: 'My parent would have done it this way.' Each has a specific context and purpose.

🎯 Scenario-Based Interview Question:

Can you use the 'this' keyword inside a static method? Why or why not?