Answer:
public class PersonRunner
{
public static void main(String[] args) {
//create a Person object
Person person = new Person("Thomas Edison", "February 11, 1847");
//create a Student object
Student student = new Student("Albert Einstein", "March 14, 1879", 12, 5.0);
//print out the details of the Person object
System.out.println("===========For Person==============");
System.out.println("Name : " + person.getName());
System.out.println("Birthday: " + person.getBirthday());
System.out.println();
//print out the details of the Student object
System.out.println("===========For Student==============");
System.out.println("Name : " + student.getName());
System.out.println("Birthday: " + student.getBirthday());
System.out.println("Grade: " + student.getGrade());
System.out.println("GPA: " + student.getGpa());
}
}
public class Person {
private String name;
private String birthday;
public Person (String name, String birthday) {
this.name = name;
this.birthday = birthday;
}
public String getBirthday(){
return birthday;
}
public String getName(){
return name;
}
}
public class Student extends Person {
private int grade;
private double gpa;
public Student(String name, String birthday, int grade, double gpa){
super(name, birthday);
this.grade = grade;
this.gpa = gpa;
}
public int getGrade(){
return grade;
}
public double getGpa(){
return gpa;
}
}
Step-by-step explanation:
The necessary code to accomplish the task is written in bold face. It contains comments explaining important parts of the code.