Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started