class
emp1
{
private int eno;
private String ename;
emp1(int no,String name)
{
System.out.println("Base
Constructor");
eno = no;
ename= name;
}
public void putemp()
{
System.out.println("Empno
: " + eno);
System.out.println("Empname : " + ename);
}
}
class
dept1 extends emp1
{
private int dno;
private String dname;
dept1(int no,String name,int eno,String
ename)
{
super(eno,ename);
System.out.println("Derived Constructor");
dno = no;
dname = name;
}
public void putdept()
{
System.out.println("Deptno
: " + dno);
System.out.println("Deptname : " + dname);
}
public static void main(String args[])
{
dept1 d = new
dept1(20,"Sales",100,"Kirthika");
d.putemp();
d.putdept();
}
}
No comments:
Post a Comment