Question: Write a class Animal which has 3 fields: i. to store its name ii. to store its life expectancy in years iii. to store
Write a class Animal which has 3 fields: i. to store its name ii. to store its life expectancy in years iii. to store its type (herbivore/carnivore) the class should have a parameterized constructor that takes these 3 field values and creates Animal objects. the class should have a method printinfo() which will print its info.
Step by Step Solution
There are 3 Steps involved in it
Heres an example implementation of the Animal class in Java with the requested fields and methods ja... View full answer
Get step-by-step solutions from verified subject matter experts
