Instead of Aand Bs go to a specific example.
class Person {
public void greet() {
System.out.println("Hello there!");
}
}
class ComputerScientist extends Person {
@Override
public void greet() {
System.out.println("Hello there! I work at the Informatics Department.");
}
public void validateAlgorithm(Algorithm a)
throws InvalidAlgorithmException {
}
}
If you have ComputerScientistlike
ComputerScientist cs = new ComputerScientist();
greet, validateAlgorithm. , Person, greet / . ComputerScientist.
Person, , , : " , ComputerScientist. , Person".
Person p = cs;
Person p = (Person) cs;
, p, , validateAlgorithm, , . p , greet this Person, .
upcasting, , , / . ComputerScientist Person.