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 overriddenmodified when using the modifier "final"
True
False
What is the output of the following program?
: class Mammal
: private void sneeze
: public Mammal int age
: System.out.printMammal;
:
: public class Platypus extends Mammal
: int sneeze return ;
: public Platypus
: System.out.printPlatypus;
:
: public static void mainString args
: new Mammal;
:
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 and For example,
add the line superANYINTEGER; to have it fixed
Which of the following complete the constructor so that this code prints out
: class Speedster
: int numSpots;
:
: public class Cheetah extends Speedster
: int numSpots;
: public Cheetahint numSpots
: INSERT CODE HERE
:
: public static void mainString args
: Speedster new Cheetah;
: System. out.printsnumSpots;
:
:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
