Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class Animal, with following specifications: Private variable name, you can use any default values. Private variable noOfLegs, you can use any default values.
Create a class Animal, with following specifications:
- Private variable name, you can use any default values.
- Private variable noOfLegs, you can use any default values.
- Public method Eat. Calling this prints out "Eating"
- Public method Talk. Calling this prints out "Talking"
- Getter/Setter for name
- Getter/Setter for noOfLegs
Create a class Dog, with following specifications:
- Extends from Animal Class
- Constructor which takes name as parameter and sets the name of the dog. Set the number of legs to 4
- Override method Eat. Calling this prints out "Eating Chimkin nuggets!"
- Override method Talk. Calling this prints out "Bark!!!"
Create a class Cow, with following specifications:
- Extends from Animal Class
- Constructor which takes name as parameter and sets the name of the cow. Set the number of legs to 4
-
- Override method Eat. Calling this prints out "Chewing grass"
- Override method Talk. Calling this prints out "Moo!!!"
Write a test program to test the classes.
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