Asked by Glòria Rivera Bataller on Jul 07, 2024

verifed

Verified

Which of the following statements about the reference super is true?

A) It must be used every time a method from the superclass is called.
B) It must be the last statement of the subclass constructor.
C) It must be the first statement of the subclass constructor.
D) It can only be used once in a program.

Reference Super

An instance where the "super" keyword is used in Java to refer explicitly to a superclass's variables or methods.

Subclass Constructor

A constructor in a subclass that is used to initialize new instances of the subclass, potentially invoking the superclass constructor as part of the initialization process.

Superclass

Within object-oriented programming, a foundational class whose properties and methods are inherited by other classes.

  • Understand the use and significance of the super and this keywords in accessing constructors and methods of a class and its superclass.
verifed

Verified Answer

JZ
Jenni ZhangJul 11, 2024
Final Answer :
C
Explanation :
The reference to the superclass, or "super", must be the first statement in the subclass constructor. This is because it is necessary to call the superclass constructor before any other actions are taken in the subclass constructor. This sets up the inheritance relationship properly and ensures that the superclass is initialized before any subclass-specific actions are taken.