Answered step by step
Verified Expert Solution
Question
1 Approved Answer
) Given the following classes, answer the following questions: public classl Animalt private int legs: private boolean hasBrain-true private String eat: public void eato System.out.printin(Eats
) Given the following classes, answer the following questions: public classl Animalt private int legs: private boolean hasBrain-true private String eat: public void eato System.out.printin("Eats food !"): public void sleep ) System.out.print ("Animal sleeps!") publie ela Pet extends Animal private int fleas: private boolean hasowner public void Sleep(){ System.out.print("Pet #leepa."); } public void eat(String food)( System. out.println( "Th pet eat " + food);} public clalp3 cat extend Pet( private boolean RitsFurBall public void meow) public void sleep (String cat) [Syaten.out.printin catleeps ") a) Write the inheritance hierarchy. Tell which one is the super class and which one the sub class. Answer: b) What are all the instance variables (, give access modifier ive data type and name) that describes the Animal class? Answer: c) What are all the instance variables (, give access modifier, give data type and name) that describes the Pet class ? Include inherited methods as well. Answer: d) What are all the instance variables (, give access modifier, data type and name) that describe the Cat class2 Include the inherited properties as well. Answer e) What are all the instance methods , give method signature->access modifier, return type, name, parameters of each in the Animal class ? Answer: f) What are all the instance methods , give method signature-access modifier, return type, name, parameters of each that describes the Pet class ? Include inherited methods as well. Answer g) What are all the instance methods , give method signature-access modifier, return type, name, parameters of each that describes the Cat class ? Include inherited methods as well Answer: h) Which super class method is overridden by a subclass? Give the method signature. Answer: i Give an example of method overloading. Give the method signature of the two methods, and mention to which class do they belong to
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