Multilevel Inheritance Program in Java
class Abaseclass //Base class { void show() //function definition of base class { System.out.println("This is the base class of B and C"); } } class Bbaseandderivedclass extends Abaseclass //Bbaseandderivedclass inherits Abaeseclass { void show() //function definition of base and derived class { System.out.println("This is the base class of C and derived class of A"); } } class CderivedclassofAandB extends Bbaseandderivedclass// Cderivedclass inherits Bbaseandderivedclass { void show() //function definition of derived class { System.out.println("This is the derived class of A and B"); } } class Mutileveldemo //Main class { public static void main(String args[]) //main function { Abaseclass a = new Abaseclass(); Bbaseandderivedclass b = new Bbaseandderivedclass(); CderivedclassofAandB c = new CderivedclassofAandB(); a.show(); b.show(); c.show(); } }
0 comments:
Post a Comment