Question: Use java Write an interface named Pet which declares a two methods: preferredFood ) which will return a string and howToCall (string name) which also

Use java
 Use java Write an interface named Pet which declares a two

Write an interface named Pet which declares a two methods: preferredFood ) which will return a string and howToCall (string name) which also returns a string. You then need to write 4 classes that implement your Pet interface. The name and description of each of these classes is: Dog howTocall() should return "Come here", a space, and then the value of name Dog's preferredFood () method should return the String "Kibble". Cat-- howTocall() should return "Open a can". cat's preferredFood() method should return the String "Meat'". Goat howTocal1() should return the value of name, a space, and then "to me". Goats's preferredFood( method should return the String "EVERYTHING". Fish - -howTocal1() should return null (you cannot call a fish). The Fish class will also need to define a field named wild of type boolean. You will also need to define a getter (named iswild) and setter (named setWild) for the instance variable. Write a constructor for Fish that has a single boolean parameter specifying if the instance is wild. Fish's preferredFood) method wll return the String "Flakes" when wild is false and the method returns "Worms" when wild is true

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!