Recall & Review
beginner
What is the purpose of the
super keyword in Java?The <code>super</code> keyword is used to refer to the parent class of the current object. It helps access parent class methods, constructors, and variables.Click to reveal answer
beginner
How do you call a parent class constructor using <code>super</code>?You call a parent class constructor by writing <code>super(arguments);</code> as the first line inside the child class constructor.Click to reveal answer
intermediate
Can <code>super</code> be used to access parent class variables if they are hidden by child class variables?Yes, <code>super.variableName</code> accesses the parent class variable when the child class has a variable with the same name.Click to reveal answer
intermediate
What happens if you don't explicitly call <code>super()</code> in a child class constructor?Java automatically inserts a call to the no-argument parent constructor
super() if you don't call it explicitly. If the parent has no no-arg constructor, it causes a compile-time error.Click to reveal answer
beginner
Can
super be used to call overridden methods in the parent class?Yes, <code>super.methodName()</code> calls the parent class version of a method that is overridden in the child class.Click to reveal answer
What does
super() do inside a child class constructor?✗ Incorrect
super() calls the parent class constructor to initialize the parent part of the object.
How do you access a parent class variable hidden by a child class variable?
✗ Incorrect
super.variableName accesses the parent class variable when hidden by the child class.
If a parent class has no no-argument constructor, what happens if the child constructor does not call
super() explicitly?✗ Incorrect
Java inserts super() automatically if not called explicitly, so if no no-arg constructor exists, compilation fails.
Which of these can
super NOT be used for?✗ Incorrect
super is for accessing parent class members, not for creating new objects.
How do you call a parent class method that is overridden in the child class?
✗ Incorrect
super.methodName() calls the parent class version of an overridden method.
Explain how the
super keyword helps in constructor chaining in Java inheritance.Think about how child and parent constructors work together.
You got /4 concepts.
Describe how
super can be used to access hidden variables and overridden methods in a child class.Consider when child class has same names as parent.
You got /4 concepts.