What is the purpose of the ‘super’ keyword?

Java MCQ: What is the purpose of the ‘super’ keyword?

a) To refer to the parent class object
b) To create a superclass
c) To call a method in the current class
d) To override a method

Answer:

a) To refer to the parent class object

Explanation:

The super keyword in Java is used to refer to the parent class object. It is commonly used to access fields, methods, and constructors of the parent class from the subclass.

Understanding super is important for managing inheritance and ensuring the correct behavior of methods and constructors in subclassing.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top