Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

) 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

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

1. Describe the power of nonverbal communication

Answered: 1 week ago