Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You have created the following base public class of Animals: public class Animal { private int noOfLegs; private String name; public Animal ( ) {
You have created the following base public class of Animals:
public class Animal
private int noOfLegs;
private String name;
public Animal
public Animalint legs, String name
this.noOfLegs legs;
this.name name;
public int getNoOfLegs
return noOfLegs;
public void setNoOfLegsint noOfLegs
this.noOfLegs noOfLegs;
public String getName
return name;
public void setNameString name
this.name name;
Assume that the Dog class extends the Animal class. If you create a Dog subclass of Animal in which favoriteTreat is also a String, which constructor accurately does this?
a
public Dogint legs, String name, String favoriteTreat
this.favoriteTreatfavoriteTreat;
superlegs name;
b
public Dogint legs, String name, String favoriteTreat
superlegs name;
c
public Dogint legs, String name, String favoriteTreat
superlegs name;
this.favoriteTreatfavoriteTreat;
d
public Dogint legs, String name, String favoriteTreat
superlegs name, favoriteTreat;
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