In the following scenario:
class Person{
public int ID;
}
class Student extends Person{
public int ID;
}
Student "hides ID field of person.
if we wanted to represent the following in the memory:
Student john = new Student();
would john object have two SEPARATE memory locations for storint Person.ID and its own?
Correct. Every class in your example has its own
int ID
id field.You can read or assign values in this way from the sub classes:
Or externally (when they are public):