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
Get step-by-step solutions from verified subject matter experts
