Professional Documents
Culture Documents
Inheritance
Inheritance
{
private String name;
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Parent()
{
System.out.println("called from parent class");
}
public Parent(String name,int id)
{
this.name=name;
this.id=id;
}
}
public Child()
{
System.out.println("called from child class");
}
public Child(String name,int id)
{
super(name,id);
}
}
public class Tester {
public static void main(String[] args)
{
Child c1=new Child("akshay",1001);
System.out.println(c1.getName());
System.out.println(c1.getId());
//Parent p1=new Parent();
}
}