Inheritance 03 Flashcards
1
Q
What is the substitution principle?
A
The substitution principle states that you can always use
a subclass object where a superclass object is
expected
Once substituted your superclass now holds and object reference to the subclass. But can’t call specialised methods.
2
Q
What is difference between upcasting and downcasting?
A
Upcasting is automatic, whereas downcasting requires a
manual cast