This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Doubt regarding a method call. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt regarding a method call." Watch "Doubt regarding a method call." New topic
Author

Doubt regarding a method call.

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Hi all, I have a doubt regarding a method call. The following code is calling method which is having a String argument. Whereas I thought that which execution ambiguity will arise. Can anyone please explain this?

Thank you all in advance, good day.


Love all, trust a few, do wrong to none.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
While passing null, it gets associated with the argument with the child in the lowest hierarchy level... In this case String extends from Object...

A similar sample code... Note that when you uncomment the method with Child4 argument, that does not extend the Child3 class, the method call using null gives error.

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Thank you @John
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
If you are getting into difficulty about which overloaded method is called when you pass null, you have probably got too many overloaded methods.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
Dennis Deems,
Your post was moved to a new topic.
 
Consider Paul's rocket mass heater.
 
subject: Doubt regarding a method call.
 
Similar Threads
method overriding doubt
Overiding Doubt
Generics Doubt
== doubt
doubt