Polymorphism Tricky Question || Method Overriding Interview question || Java Interview question

preview_player
Показать описание
practice questions on polymorphism in java,
scenario based questions on polymorphism,
what are different ways to achieve or implement polymorphism in java? ,
what is interface in java interview questions,
interview questions on encapsulation in java,
Рекомендации по теме
Комментарии
Автор

Try calling same name field and you find out that fields do not override!
Also, try overriding private methods - they do not override either.
sir can u explain this ??

techkid
Автор

when we have two classes i.e. base class and extended class and the method name in both classes is same,
And we have created the object of derived class,
And when calling the derived class method, the derived class method will be called and not the base class method.
then Here we can say that the derived class method override the base class method and this is called method overriding ;

techkid
Автор

😂Try calling same name field and you find out that fields do not override!
Also, try overriding private methods - they do not override either.

Кукусик-еэ