Thursday, August 13, 2020

write a java program for Hybrid inheritance

 class Hybri 

{

int bonus=2000,sal=5000;

}

class chlid1 extends Hybri

{

void showchild1()

{

System.out.println("bonus"+bonus+"sal"+sal);

}

};

class chlid2 extends Hybri

{

void showchild2()

{

System.out.println("bonus"+bonus+"sal"+sal);

}

};

class Driver1

{

public static void main(String[] args) 

{

chlid1 c1=new chlid1();

        chlid2 c2=new chlid2();

c1.showchild1();

c2.showchild2();

}

}


No comments:

Post a Comment