Hello. We're going into Constructora and super, using extends, subclasses etc. I have this code:
class Student {
private String name;
private String matric_no;
public Student(String n, String m) {
name = n;
matric_no = m;
}
}
class UndergradStudent extends Student {
private String programme;
public UndergradStudent(String n, String m, String p) {
programme = p;
super(n, m);
}
}
class PostgradStudent extends Student {
private String supervisor;
public PostgradStudent(String s) {
supervisor = s;
}
}
and there is a compilation error in the subclasses. i understand that UndergradStudent inherits the private fields of Student but cannot do anything with it because its private, would that cause the error? Could someone explain why there is an error please? Thanks in advance