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
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
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
#10 - Auto Trigger Playwright Tests using Jenkins with GIT WebHook and NGROK ProxyChrome v111.x issue is fixed now in Latest Selenium Version#18 - Focus on an Element using Playwright + TypescriptPart 6 - POST CALL with POJO Class || Playwright Java API Automation#32 - Various Console Log Methods in JavaScript || Don't use console.log(), use this instead of.#7 - Mobile Browser (Android & iOS) testing with #testRigorSelenium & Java Training Boot Camp – Regular Batch (30th March 2023 – 8:15 AM IST/ 7:45 PM PST)#17 - Method Overriding in JavaScript50 Java Keywords in just 4 mins || Naveen Automation Labs#8 - Data-Test-Id or Test-Data-ID - Locate by test id in Playwright+Typescript#20 - XPath Locator in Playwright || Playwright with Java#7 - Call PUT and DELETE APIs using #Gatling#2 - Type, Type Inference, Type Annotations in TypeScript#29 - CallBack Hell Vs Promise Chaining in JavaScriptWaitForEnabled and WaitForDisplayed in WebDriverIO - Part - 15Wait for File Download using FluentWait in SeleniumO(N Log N) - Linear Logarithmic Time Complexity || Merge Sort AlgorithmRemove Elements and Empty an Array in JavaScript - Part - 14Singleton Pattern with Serialization - How to prevent Object creation during SerializationLabels in java - Tricky Java QuestionPart 8 - PUT CALL || POJO Class || Playwright Java API Automation