Загрузка страницы

Can we override a static method in child class? || Famous Interview Question

Can we override a static method in child class? || Famous Interview Question

Static methods can not be overridden in the exact sense of the word, but they can hide parent static methods

In practice it means that que compiler will decide which method to execute at compile time, and not in runtime, as it does with overridden instance methods.

For a neat example have a look here.

And this is java documentation explaining the difference between overriding instance methods and hiding class (static) methods.

Overriding: Overriding in Java simply means that the particular method would be called based on the run time type of the object and not on the compile time type of it (which is the case with overriden static methods)

Hiding: Parent class methods that are static are not part of a child class (although they are accessible), so there is no question of overriding it. Even if you add another static method in a subclass, identical to the one in its parent class, this subclass static method is unique and distinct from the static method in its parent class. Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
https://www.youtube.com/c/Naveen%20AutomationLabs?sub_confirmation=1

Follow me on my Facebook Page:
https://www.facebook.com/groups/naveenqtpexpert/

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
https://t.me/joinchat/COJqZUPB02r5sB73YMdXEw

Paid courses (Recorded) videos:
Java & Selenium Course: http://www.naveenautomationlabs.com/p/course-content-selenium-webdriver-is.html
API Course: http://www.naveenautomationlabs.com/p/syllabus-course-content-manual-testing.html ➡️Get Our Courses✔️
📗 Get My Paid Courses at
Paid courses (Recorded) videos:
Java & Selenium Course: http://www.naveenautomationlabs.com/p/course-content-selenium-webdriver-is.html
API Course: http://www.naveenautomationlabs.com/p/syllabus-course-content-manual-testing.html
-------------------------------

✔️SOCIAL NETWORKS
Facebook: https://www.facebook.com/groups/naveenqtpexpert/
Twitter: https://twitter.com/naveenkhunteta
Blog: http://www.naveenautomationlabs.com
--------------------------------

Support My Channel✔️Or Buy Me A Coffee
Paypal: https://paypal.me/naveenkhunteta
Google Pay: naveenanimation20@gmail.com
--------------------------------
✔️Thanks for watching!
देखने के लिए धन्यवाद
Благодаря за гледането
感谢您观看
Merci d'avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة

Видео Can we override a static method in child class? || Famous Interview Question канала Naveen AutomationLabs
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
15 мая 2019 г. 0:11:20
00:14:46
Яндекс.Метрика