The Artima Developer Community
Sponsored Link

Java Answers Forum
something

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Kiran Kumar

Posts: 12
Nickname: k3
Registered: May, 2007

something Posted: May 29, 2007 4:33 AM
Reply to this message Reply
Advertisement
Hi

Can any one help me in understanding this concept.

<java>

class A{}
class B extends A{}

class SomeThing{

void meth1( A a ){
System.out.println("Inside A");
}
void meth1( B b ){
System.out.println("Inside B");
}

public static void main( String []args ){
SomeThing t = new SomeThing();
t.meth1( null );
}
}

</java>

And this method call of "meth1( null )" in the main method calls the "meth1( B b )". Why?

I know that any method call with a null as argument calls the most specific overloaded method. But why?

Kindly provide me with an answer.

Regards
Kiran

Topic: something Previous Topic   Next Topic Topic: How best to introduce a child to programming?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use