Inheritance (Extends)
Lesson 34Author : 🦒
Last Updated : October, 2017
Code
class Chef{
public void makeChicken(){
System.out.println("The chef makes chicken");
}
public void makeSalad(){
System.out.println("The chef makes salad");
}
public void makeSpecialDish(){
System.out.println("The chef makes a special dish");
}
}
class ItalianChef extends Chef{
public void makePasta(){
System.out.println("The chef makes pasta");
}
@Override
public void makeSpecialDish(){
System.out.println("The chef makes chicken parm");
}
}
public class App{
public static void main(String [] args){
Chef myChef = new Chef();
myChef.makeChicken();
ItalianChef myItalianChef = new ItalianChef();
myItalianChef.makeChicken();
}
}