HYBRID INHERITANCE
HYBRID INHERITANCE
class Employee
{
String ename;
int ecode;
void accept(String n, int e)
{ename=n;
ecode=e;}
void show()
{System.out.print("Name: "+ename+" Age: "+ecode);}
}
class Manager extends Employee
{
int salary;
void accept_s(int s)
{salary=s;}
void show_s()
{System.out.print("\nSalary= "+salary);}
}
class Worker extends Employee
{
int wages;
void accept_N(int w)
{wages=w;}
void show_W()
{
System.out.print("\nWages= "+wages);
}
}
class Apprentice extends Worker
{
int noOfDays;
void accept_a(int a)
{noOfDays=a;}
void show_a()
{
System.out.print("\nNo of days= "+noOfDays);
}
public static void main(String a[])
{
Apprentice ob=new Apprentice();
System.out.print("\n");
ob.accept("AAA",111);
ob.accept_N(4444);
ob.accept_a(5555);
ob.show();
ob.show_W();
ob.show_a();
Manager obb= new Manager();
obb.accept_s(22222);
obb.show_s();
}
}
Comments
Post a Comment