classFruit{voidcutting(){System.out.print("Cutting Fruit ");}}classMangoextendsFruit{voidcutting(){super.cutting();//invokes the super class methodSystem.out.println("Mango");}}classAppleextendsFruit{voidcutting(){super.cutting();//invokes the super class methodSystem.out.println("Apple");}}classKWextendsFruit{publicstaticvoidmain(Stringargs[]){Fruitm=newMango();//Mango objectm.cutting();Fruita=newApple();//Apple objecta.cutting();}}
Output
kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
Cutting Fruit Mango
Cutting Fruit Apple
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?