Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Please tell me output flow for this program  RSS feed

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,


So when we call setName(null) the overloaded String method will get called .so please tell me the flow how the null is assigned to String here any how Object can take place of this part right...?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When there are multiple possibilities, Java will choose the most specific method. Since String is a subclass of Object, String is more specific, so the String version will be called. The version without any arguments isn't applicable when you call the method with one argument, even when the argument is null.

15.12.2.5 Choosing the Most Specific Method in the Java Language Specification explains all the details.
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sir,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!