Hello
I'm trying to understand some basics of classes that extends from other classes. I wonder if I could get some help.
Assume I have the following class
public class Person{ private String name; private int age; private String adress; public Person(String n, int ag, String adr){ name = n; age = ag; adress = adr; } }
and this one below
public class Student extends Person{ private double gpa; public Student(String n, int ag, String adr, double gpa) { super(n, ag, adr); this.gpa = gpa; } }
What's the difference between these two lines of code below? The parameters are not interesting though, I'm just trying to figure out what they are instances of.
Student student = new Student("name1", 20, "adress1", 50); Person student2 = new Student("name", 21, "adress2", 50);
I mean in the first one it's Student student = new Student(...). On the second line there is [B]Person[/B] student2 = new Student(...).
Is student2 a "Student" or "Person"?
Thanks in advance.
Best regards,
Robin.