class Cat {
String whatAmI() {
return “I’m a Cat!”;
}}
class Kitten extends Cat {
String whatAmI() {
return “I’m a Kitten!”;
}}
class NinjaKitten extends Kitten {
String isKickedBy(Kitten k) { return “Ouch!”; }
}
Cat bob = new NinjaKitten();
System.out.println(“Bob: ” + bob.whatAmI());
My question is what is bob’s static type and what is his dynamic type?
Bob’s static type would be Cat, and his dynamic type, NinjaKitten (which is awesome by the way).
Hope that helps!