Код: Выделить всё
class Apple {
String type;
setType(){
System.out.println("inside apple class");
this.type = "apple";
}
}
class RedApple extends Apple {
String type;
setType() {
System.out.println("inside red-apple class");
this.type = "redapple";
}
}
int main {
RedApple red = new RedApple();
Apple apple = (Apple) red;
apple.setType();
}
Код: Выделить всё
"inside red-apple class”
Подробнее здесь: https://stackoverflow.com/questions/672 ... ng-in-java