Create a Java program to demonstrate abstract class inheritance and method overriding
abstract class Fruit { abstract void displayTaste(); } class Apple extends Fruit { @Override void displayTaste() { System.out.println("Apple is sweet"); } } class Orange extends Fruit { @Override void displayTaste() { System.out.println("Orange is tangy"); } } public class Main { public static void main(String[] args) { Fruit apple = new Apple(); Fruit orange = new Orange(); apple.displayTaste(); orange.displayTaste(); } }
Apple is sweet Orange is tangy
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions