Module: | Core Architecture, Basics & Control Flow
Q20: Consider the following statements regarding constructor chaining and the super() call:
1. The super() method call is utilized to invoke the constructor of the immediate parent class and must strictly be the absolute first statement inside the child class constructor.
2. If a developer does not explicitly write a super() or this() call in a constructor, the Java compiler automatically injects a default no-argument super() call on the first line.
3. The super() call can be placed inside standard instance methods to re-initialize the parent object's memory state after instantiation.
Which of the above statements is/are correct?
2. If a developer does not explicitly write a super() or this() call in a constructor, the Java compiler automatically injects a default no-argument super() call on the first line.
3. The super() call can be placed inside standard instance methods to re-initialize the parent object's memory state after instantiation.
Which of the above statements is/are correct?
✅ Correct Answer: A
🎯 Quick Answer:
The correct combination is 1 and 2. Statement 3 is incorrect because the super() method call is strictly restricted to constructor blocks and cannot be executed from standard instance methods.Structural Breakdown: In the constructor execution hierarchy, memory must be initialized from the top-down.
Therefore, super() must physically be the first executable statement.
It can optionally take parameters to call specific overloaded parent constructors.
Historical/Related Context: The automatic injection of the no-argument super() call by the Java compiler was designed to ensure architectural stability.
In early languages, developers often forgot to initialize the base class, resulting in unstable child objects attempting to utilize uninitialized parent variables.
Causal Reasoning: The compiler mandates super() as the first line to guarantee that the fundamental foundational state of the parent object is completely constructed and secured before the child class is permitted to append its specialized state or execute its custom logic.