Answered step by step
Verified Expert Solution
Link Copied!

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 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:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What powers does a trustee have?

Answered: 1 week ago

Question

=+ (d) Show that Y ,, Y2, ... are independent.

Answered: 1 week ago