Beim getSize() in BigAnimal-Klasse und ihre überschriebene Methode in Dragon Klasse , alles ist klar , weil die Methode schon protected ist. Aber die getSize() Methode in SmallAnimal Klasse hat keinen Modifikator . Das heißt , sie hat den Standard-Modifikator , und wir haben gesehen , dass geerbte Klassen keinen Zugriff zu solche Methoden hat . Kann jemand mir das erklären ?
package de.codegym.task.task15.task1502;
/*
OOP: Tierische Vererbung
*/
public class Solution {
// Add the Goose and Dragon classes here
public static void main(String[] args) {
}
public static class BigAnimal {
protected String getSize() {
return "wie ein Dinosaurier";
}
}
public static class SmallAnimal {
String getSize() {
return "wie eine Katze";
}
}
public static class Goose extends SmallAnimal{
public String getSize() {
return "Eine Gans ist klein," + super.getSize();
}
}
public static class Dragon extends BigAnimal {
public String getSize() {
return "Ein Drache ist groß," + super.getSize();
}
}
}