public class Person
{
private String name;
private int age;
public Person(String name, int age)
{
super();
this.name = name;
this.age = age;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
}
Student.java public class Student extends Person
{
private String schoolName;
public Student(String name, int age, String schoolName)
{
super(name, age);
this.schoolName = schoolName;
}
public String getSchoolName()
{
return schoolName;
}
public void setSchoolName(String schoolName)
{
this.schoolName = schoolName;
}
}
SuperTest.java public class SuperTest
{
public static void main(String[] args)
{
Student studentObj = new Student("Peter",12,"Baldwin School");
System.out.println("name = "+studentObj.getName());
System.out.println("age = "+studentObj.getAge());
System.out.println("school name = "+studentObj.getSchoolName());
}
}