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 

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

1 Expert Approved Answer
Step: 1 Unlock

Heres an example implementation of the Animal class in Java with the requested fields and methods ja... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!