Question: java. Question 2: Practice Polymorphism- Food A Assume you have a parent class called Food with one instance data variable: private String name. The class

java.

Question 2: Practice Polymorphism- Food A

Assume you have a parent class called Food with one instance data variable: private String name. The class has one constructor that takes the name as a parameter, getters and setters for name, and a toString that outputs the name.

  • Write a child class called Vegetable with one additional variable describing whether or not the vegetable is green.
  • Write two constructors: one that takes in all information about a vegetable and one that uses a default value to indicate that a vegetable IS green.
  • Write getters and setters, a toString, and an equals method.

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!