INSTRUCTOR
Modify the following program by adding 2 more subclasses for Fruit which same class as Apple. Create another two sub-class under Apple such as green and red apple. Add suitable variables in all classes and create any methods that can describe the type of the class.
class Fruit {
private String name;
public Fruit(String name) {
this.name = name;
System.out.println("Fruit constructor is invoked");
}
}
public class Apple extends Fruit {
public Apple(String name) {
super(name);
System.out.println(“Apple constructor is invoked");
}
}
SUBMISSION
Submit your coding before 8.30 am on Wednesday, 28 April.
INSTRUCTOR Modify the following program by adding 2 more subclasses for Fruit which same class as Apple. Create another two sub-class under Apple such as green and red apple. Add suitable variables in all classes and create any methods that can describe the type of the class.
class Fruit { private String name; public Fruit(String name) { this.name = name; System.out.println("Fruit constructor is invoked"); } }
public class Apple extends Fruit { public Apple(String name) { super(name);
System.out.println(“Apple constructor is invoked"); } }
SUBMISSION Submit your coding before 8.30 am on Wednesday, 28 April.