Method Overriding - Day 6 Flashcards
Dynamic polymorphism
Like static polymorphism. Polymorphism can also occur at runtime, this is dynamic polymorphism.
Accomplished by overriding the parent method in the child class.
When overriding
The child class should have the same signature as the parent class.
Method should not have a weaker access modifier
Private methods are not overridden
Dynamic binding
Datatype = new ();
Version of the method that will be called is determined by the objects this is taken at runtime.
Annotations
Meta-data that provides data about the program and is not part of the program itself
“@override”
Gives additional information to compiler
Super keyword
Invokes a parent class method from a child class method
Access a parent class instance variable in the child class there is a variable in the child class with the same name
Overloading vs overriding
Overloading is compile-time polymorphism
Overriding is runtime polymorphism