Tricky Interview Question : Pass null argument with method overloading of String and Object types

preview_player
Показать описание
In this video, I have explained one tricky java interview question: Interview Question : Pass null argument with method overloading with String and Object types

In the case of null, null is valid for both string and object. So, which method will be called?

Object is a parent class and string is a child class. While resolving the overloading method, the compiler always uses the presidency for the child type argument. So, the compiler will call the method with the string argument.

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Naveen AutomationLabs Paid Courses:
Java & Selenium:

Java & API +POSTMAN + RestAssured + HttpClient:
Рекомендации по теме
Комментарии
Автор

Answer is string Argument.
Because, resolving the overloaded method compiler will always gives precedence to child class when compared with parent ..

yogeshnakat
Автор

Got to know a interesting fact that how compiler behaves is such situations 👍😊, thanks Naveen

SarangHoley
Автор

I thought that object class is parent class so it would give priority to object, but today I learn new thing,
Keep it up to make this kind of vedio🙏🙏🙏

archanagupta
Автор

Once I have been asked some questions on interview
1) any 5 way to prevent your class to being inherited
2) what if when we write main method inside abstract class
3) main method overloading vs overriding and explain difference...
N surprisingly I was unable to answer 😂😂😂 pls sir you may take this question for next video if it make sense 🤗

SameerKumar-yuxi
Автор

String as the method overload in child class gets priority

MamathaAvula
Автор

Excellent . Learning new everyday here. 👏

skb
Автор

Object class I expected later when you were executing I understood that out put brother

pandudamera
Автор

whenever u use string and stringbuffer classes both are child classes and both will match the argument since both will match the orgument then u will get compile time error. correct me if i am wrong. Thanks Naveen sir each and every video very informative

Bbangaram-du
Автор

Insightful !
sharing to as many as possible

sridharlanka
Автор

the current set of programs you have been covering is really nice naveen please do videos of things like these please dont do videos of common ones unless there are lots of requests

mahatheedandibhotla
Автор

Thank you for such informative videos👍

tanugupta
Автор

BRO please make more this type of interview question videos... Try to give two videos a day.. this will help us in interview

aminurrahaman
Автор

These kind of questions are mostly asked in OCJP certification, may be we can collect the questions from there and do a Seperate series for it..

hello
Автор

Good interview questions sir. . thank you

maheshtenapali
Автор

Hi Naveen you are doing great job testing community please try to cover security testing with one tool, database testing with tool ( etl) ( sql and nosql db), bigdata testing with one tool do series.Everyone one run behind selenium java python api so much content available in youtube. Please try to cover these parts atleast it will gain knowledge to other areas. Without watching your content testing no value

maheshz
Автор

Sir you take manual testing project session
Please tell me I want to do project

funnyworld_
Автор

I have two methods with same name and same number of parameters. Ome takes int one takes double. In main I make a object of class n call that method (10) . Which one method should it call integer one or double One

jyotibaviskar
Автор

String in overloading child get more priority than object

arnavpatil
Автор

Can abstract class have main method? try answering theoretically.

arvindsah
Автор

Hey naveen I m a big big big fan of your..
I need to ask like suggest some satisfying books that will give some ideas about The automations...
Plz plz share the link

rahulsinha