Question: ( JAVA) Call all the setters for animal1 object ( created in step f) .Use any appropriate values to set the instance variables. Answer: Call


(JAVA) Call all the setters for animal1 object ( created in step f) .Use any appropriate values to set the instance variables.
Answer:
Call all the setters for all instance variables ( both native and inherited) of pet1 object ( created in step e) .Use any appropriate values to set the instance variables.
Answer:
Assume there is another instance variable in Pet class called petType of String type. Write a method setPetType that will set the value of petType using the following logic.
If the value of legs is 0, petType is Snake ; If the value of legs is 2, petType = monkey ; if the value of petType is 4, petType= four-legged; else petType = insect.
Answer:
Call setType method described in the problem above, for pet1 object.
Answer:
Suppose the Pet class has another sub class called Cat. Assume this class has a private Boolean instance variable called likesToScratch. Override the printPetInstVar() method by printing out only the value of likesToScratch and hasOwner.
Answer:
Suppose the Pet class has another sub class called Cat. Assume this class has a Boolean instance variable called likesToScratch. Override the printPetInstVar() method by printing out the values of all instance variables including those of the Pet class and those of the Cat class.
Answer:
Suppose the Pet class has another sub class called Cat. Override the getFleas method by doubling the value returned by the super classs getFleas method.
Answer:
public class Animal i protected int legs: protected String eat: public int getLegs ) return legs: public void setLegs (int legs) legs; this. legs = public String getEat ) return eat: public void setEat (String eat) this.eat eat: public Animal) t this. legs = 0; this. eat = "f d"; public Animal (int legs, String eat) this. legs = legs; this.eat eat
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
