SINGLE LEVEL INHERITANCE IN JAVA
SINGLE LEVEL INHERITANCE IN JAVA
class Employee
{
String ename;
int ecode;
Employee()
{}
Employee(String n,int c)
{
ename=n; ecode=c;
}
void show()
{
System.out.print("\nNAME: "+ename);
System.out.print("\nCODE: "+ecode);
}
}
class Manager extends Employee
{
String dept_name;
int salary;
Manager()
{}
Manager(String n,int e,String d,int s)
{
super(n,e);
dept_name=d; salary=s;
}
void show()
{
System.out.print("\nNAME: "+ename);
System.out.print("\nCODE: "+ecode);
System.out.print("\nDEPT_NAME: "+dept_name);
System.out.print("\nSalary: "+salary);
}
}
class pcsk
{
public static void main(String[] args) {
Manager m=new Manager("ABC",23,"XYZ",2000);
System.out.print("\nDETALS OF MANAGER\n");
m.show();
}
}
Comments
Post a Comment