STIA1123-A202-GROUP-I / EXERCISES

0 stars 0 forks source link

Exercise 4.2 #15

Closed azmanyasin closed 3 years ago

azmanyasin commented 3 years ago

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.