Inherently good for you.
class Student
introduce()
getName()
getBirthday()
getGpa()
class Professor
introduce()
getName()
getBirthday()
getClassName()
Student
Professor
?
Person
public class Professor extends Person {
}
AKA:
public class Person {
public String name;
public String birthday;
public Person() { ... }
public String getName() { ... }
public String getBirthday() { ... }
public String introduce() { ... }
}
public class Professor extends Person {
public String className;
public Professor() { ... }
public String getClassName() { ... }
}
public class Student extends Person {
public float gpa;
public Student() { ... }
public float getGPA() { ... }
}
public static void main(String[] args) {
....
Student student = new Student("Charles", "4/11/1995", 3.4);
System.out.println(student.introduce());
}
Where is introduce()?
Student -> Person
Nope!
Yep!
public class Professor extends Person {
public String className;
public Professor() { ... }
public String getClassName() { ... }
public String introduce() { ... }
}
Declaring a new field
Declaring a new method
Override a parent method