In: Computer Science
To make class DressShirt inherit the functionality of both Clothing and Shirt (from previous question), the class header would be:
Group of answer choices
public class DressShirt inherits Shirt, Clothing
public class DressShirt inherits Shirt
public class DressShirt extends Shirt
public class DressShirt extends Shirt, Clothing
If Shirt inherits Clothing, then Shirt has direct access to the ______ members of Clothing
Group of answer choices
public and protected
public
private
protected
private and protected
Shirt inherits Clothing. What is the first thing that must happen in the Shirt constructor?
Group of answer choices
Initialize the required Shirt fields
Call the Clothing constructor
Create all objects required for Shirt fields
Map the parameters coming into the constructor to Shirt fields
Question:
To make class DressShirt inherit the functionality of both Clothing
and Shirt (from the previous question), the class header would
be:
Ans: public class
DressShirt extends Shirt, Clothing
Whenever we need to inherit the functionality of the classes, we
need to use the keyword "extends"
Since we need to inherit the functionality of the two classes Shirt
and Clothing.
We need to use the extend keyword followed by the class names that
we need to implement as:
public class DressShirt extends Shirt, Clothing
Question:
If Shirt inherits Clothing, then Shirt has direct access to the
______ members of Clothing
Ans: public and
protected
As a class inherits other classes, then the inherited class which is subclass has direct access to the public and protected members of the class Clothing which is the superclass.
Question:
Shirt inherits Clothing. What is the first thing that must happen
in the Shirt constructor?
Ans: Call the
Clothing constructor
The first thing that happens in the shirt class after inheriting the Clothing class is it will call the clothing constructor.
(Feel free to drop me a comment, If you need any help)
Hope this Helps!!!
Please upvote as well, If you got the answer?
If not please comment, I will Help you with that...