+ 3

when we use inheritance in Java does overriding happen automatically ????

java

23rd Jul 2018, 7:04 AM
Aahnik Daw
Aahnik Daw - avatar
4 ответов
+ 2
No, you need to create an overriding method (with the @Override annotation) within the child class. Nothing is overridden automatically. The overriding instance method has to have the same name as the method being overridden. Edit: I might add, that everything is *inherited* automatically.
23rd Jul 2018, 2:00 PM
Jukka Kuusto
Jukka Kuusto - avatar
23rd Jul 2018, 7:32 AM
KrOW
KrOW - avatar
+ 1
overriding of the methods should be done by the programmer. but the binding itself is done automatically and it is called dynamic binding. unlike c++ where the programmer should code for dynamic binding.
28th Jul 2018, 3:28 AM
Abdul Wahab Khan
Abdul Wahab Khan - avatar
- 1
You mean without doing what?
23rd Jul 2018, 7:29 AM
Jonas Schröter
Jonas Schröter - avatar