Podcast Beta
Questions and Answers
When a Student object is instantiated, the default constructor of its superclass is invoked implicitly to do the necessary ______
initializations
To illustrate this, consider the following ______, public static void main( String[] args ){ Student anna = new Student(); }
code
The program flow of inheritance: The ______ keyword
super
A subclass can also explicitly call a constructor of its immediate ______
Signup and view all the answers
Few things to remember when using the ______ constructor call:
Signup and view all the answers
This is done by using the ______ constructor call
Signup and view all the answers
A super constructor call in the constructor of a subclass will result in the execution of relevant constructor from the ______, based on the arguments passed
Signup and view all the answers
For example, given our previous example classes Person and Student, we show an example of a ______ constructor call
Signup and view all the answers
The super() call MUST OCCUR AS THE ______ STATEMENT IN A CONSTRUCTOR
Signup and view all the answers
The super() call can only be used in a ______ definition
Signup and view all the answers
In Java, all classes, including the classes that make up the Java API, are subclassed from the ______ superclass.
Signup and view all the answers
A sample class hierarchy is shown below. Superclass - Any class above a specific class in the class ______.
Signup and view all the answers
Once a behavior (method) is defined in a superclass, that behavior is automatically inherited by all ______.
Signup and view all the answers
A subclass only needs to implement the differences between itself and the ______.
Signup and view all the answers
To derive a class, we use the ______ keyword.
Signup and view all the answers
Suppose we have a parent class called ______.
Signup and view all the answers
Study Notes
Object Instantiation and Inheritance
- When a Student object is instantiated, the default constructor of its superclass is invoked implicitly to do the necessary initialization.
- The program flow of inheritance is illustrated using the
extends
keyword. - A subclass can also explicitly call a constructor of its immediate superclass using the
super
keyword.
Super Constructor Call
- A super constructor call in the constructor of a subclass will result in the execution of the relevant constructor from the superclass, based on the arguments passed.
- The
super()
call must occur as the first statement in a constructor. - The
super()
call can only be used in a constructor definition.
Class Hierarchy
- In Java, all classes, including the classes that make up the Java API, are subclassed from the
Object
superclass. - A superclass is any class above a specific class in the class hierarchy.
- Once a behavior (method) is defined in a superclass, that behavior is automatically inherited by all subclasses.
- A subclass only needs to implement the differences between itself and the superclass.
Class Derivation
- To derive a class, we use the
extends
keyword. - Suppose we have a parent class called
Person
, and we can derive a subclassStudent
from it.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz covers the concepts of inheritance in Java programming, including defining super classes and subclasses, overriding methods, and creating final methods and classes. It also discusses the Java class hierarchy and the Object superclass.