Java program for Multilevel Inheritance
KW.java
class Bank
{
    void Bonus()
    {
       System.out.print("Festival Bonus: ");
    }  
}
class WhiteBank extends Bank
{
    void WhiteBankBonus()
    {
        super.Bonus();
        System.out.println("WhiteBank 1500");
    }
}
class GreenBank extends WhiteBank
{
    void GreenBankBonus()
    {
        super.WhiteBankBonus();
        super.Bonus();
        System.out.println("GreenBank 500");
    }
}

class KW 
{
    public static void main(String[] args) 
    {
        GreenBank gb=new GreenBank();
        gb.GreenBankBonus();
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Festival Bonus: WhiteBank 1500 Festival Bonus: GreenBank 500 kodingwindow@kw:~$
Advertisement