Question: subclass and superclass are also known as parent and child classes respectively. True False We cannot have attributes and methods overridden / modified when using

subclass and superclass are also known as
parent and child classes respectively.
True
False
We cannot have attributes and methods overridden/modified when using the modifier "final"
True
False
What is the output of the following program?
01: class Mammal {
02: private void sneeze ){}
03: public Mammal (int age){
04: , System.out.print("Mammal");
05: }
06: public class Platypus extends Mammal {
07: int sneeze(){ return 1 ; }
08: public Platypus(){
09: , System.out.print("Platypus");
10: }
11: public static void main(String args){
12: , new Mammal(5);
13: }}
Platypus
Mammal
PlatypusMammal
MammalPlatypus
Platypus class inherits from Mammal class, so Platypus should have a constructor that pass in exact one integer argument
Platypus class inherits from Mammal class, so we must define an implicit super constructor Mammal between the line 8 and 9. For example,
add the line super(ANY_INTEGER); to have it fixed
Which of the following complete the constructor so that this code prints out 50?
01: class Speedster {
02: int numSpots;
03: }
04: public class Cheetah extends Speedster {
05: int numSpots;
06: public Cheetah(int numSpots){
07: // INSERT CODE HERE
08: }
09: public static void main(String args){
10: , Speedster s= new Cheetah(50);
11: , System. out.print(s.numSpots);
12: }
13:
 subclass and superclass are also known as parent and child classes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!