Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If you wanted to create a class of Animals, you could use the following base class: public class Animal { private int noOfLegs; private String

If you wanted to create a class of Animals, you could use the following base class:
public class Animal {
private int noOfLegs;
private String name;
public Animal(){}
public Animal(int legs, String name){
this.noOfLegs = legs;
this.name = name;
}
public int getNoOfLegs(){
return noOfLegs;
}
public void setNoOfLegs(int noOfLegs){
this.noOfLegs = noOfLegs;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
}
Which selection would create a subclass of Bird with a constructor that receives the number of wings and sets the legs to 2 rather than require user input?
public class Animal extends Bird {
private int noOfWings;
public Bird(int legs, String name, int wings){
super(legs, name);
this.noOfWings=wings;
}
}
public class Bird extends Animal {
private int noOfWings;
public Bird(int legs, String name, int wings){
super(legs, name);
this.noOfWings=wings;
}
}
public class Bird extends Animal {
private int noOfWings;
public Bird(String name, int wings){
super(2, name);
this.noOfWings=wings;
}
}
public class Bird extends Animal {
private int noOfWings;
public Bird (int wings){
super();
this.noOfWings=wings;
}
}

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

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions