I agree with @BunsenBurns, there is no consistency in your example, it's really bad honestly... Banana has sugar, fun hello(), fun writeSomething(), super confusing. Try to make it more structured next time mate...
Abstract class is a class that you don't want someone else to create an object from it while an interface class is a class that is used when there are functions or properties that you want to use in another class, but can't inherit from it for example; class Vehicle can't inherit from class Animal which has a method roar that you want to use with class Vehicle because a Vehicle cannot be an Animal, so an interface (let's call the interface Roarable) can be created with a method roar(), and the interface can now be inherited by class Vehicle in order to use/implement roar() method.
There are probably a million better examples. But these are the ones I went with at the time, and if you got the basic concept, then that's all that matters :)
Nice explained!
I agree with @BunsenBurns, there is no consistency in your example, it's really bad honestly... Banana has sugar, fun hello(), fun writeSomething(), super confusing. Try to make it more structured next time mate...
What's the difference between an Abstract Class and an Interface?
Abstract class is a class that you don't want someone else to create an object from it while an interface class is a class that is used when there are functions or properties that you want to use in another class, but can't inherit from it for example; class Vehicle can't inherit from class Animal which has a method roar that you want to use with class Vehicle because a Vehicle cannot be an Animal, so an interface (let's call the interface Roarable) can be created with a method roar(), and the interface can now be inherited by class Vehicle in order to use/implement roar() method.
what strange choices of classes... why have apple implement banana? wouldn't it make far more sense to have defined a fruit superclass or interface?
There are probably a million better examples. But these are the ones I went with at the time, and if you got the basic concept, then that's all that matters :)