Type Here to Get Search Results !

What is the purpose of the super keyword in a subclass?

0

 What is the purpose of the super keyword in a subclass?

A) To create a new instance of a class.
B) To call a method from the subclass.
C) To access methods and properties of the superclass.
D) To define abstract methods.

Answer: C) To access methods and properties of the superclass.

Explanation: The super keyword is used to refer to the superclass (parent class) of the current object. It allows a subclass to access methods and properties defined in the superclass, enabling the subclass to call overridden methods or constructors. This is useful for code reuse and maintaining the hierarchy of classes.

Post a Comment

0 Comments