Question: Consider the following class declarations. public class Plant { public String name; public Plant(String name) { this.name = name; } } public class Vegetable extends

Consider the following class declarations. public class Plant { public String name; public Plant(String name) { this.name = name; } } public class Vegetable extends Plant { public String colour; public double weightInKg; public Vegetable(String name, String colour, double weightInKg) { // // // } } Write the body of the Vegetable class constructor as indicated by the comment lines in the answer box below. For Example: Vegetable v = new Vegetable("Carrot", "orange", 0.2); System.out.print(v.name + " " + v.colour + " " + v.weightInKg + "kg"); gives output : Carrot orange 0.2kg

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!