public String methodThatTakesFruitClassButNotBanana
This is exact opposite of Liskov Substitution Principle and how polymorphism works. Since Banana extends Fruit
there is a requirement that any method that takes a Fruit
accepts a Banana
.
If you have to, you need to check dynamic type and throw exception, the compiler cannot do this for you.