Internet resources
@see Oracle Java Tutorial
@see Java Polymorphism
@see heritage and polymorphism (French)
@see Heritage en Java (French)
@see Abstract and Interface (French)
Implementation model
Polymorphism/Interface/Inheritance model
interface Humanable
see
eat
walk
run
rest
rip
interface Doctor
heal
interface Warrior
fight
Interface Warlock
cast
Abstract Superman implements interface Human, Doctor, Warrior, Warlock
Human
see ="Everything"
eat="Never"
walk = return "run"
run = return "flash run "
rest = return "never"
rip = return "never"
Doctor
heal = return "Surgeon"
Warrior
fight = return "Marine"
Warlock
cast = return "Fireball"
Class Somebody extends Superman
Human h = new Human
h.see="Blind"
h.eat="allways"
h.walk = "walk"
h.run = "run"
h.rest = "every night"
h.rip = return "80 years"
Doctor d = new Doctor
d.heal="cannot heal"
Warrior w1 = new Warrior
w1.figth="cannot fight"
Warlock w2 = New Warlock
w2.cast="cannot cast"
Tips
Interfaces (abstract) are used for defining object behaviour. the behaviour can be understood and noted as ‘object’ followed by ‘able’ like ‘Serializable’, if you cannot say ‘object’able you should not create an interface, but an object. (abstract or POJO)
Super class are used for defining the « standard behavior » of objects
An object is defined by its class, once the object exists the object can be manipulated by any super.class without loosing its own properties. (a sub-class bears its own properties which add properties of the existing properties of its super class).