one question about overloading

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
icepeanuts
Posts: 53
Joined: Thu Nov 22, 2012 12:01 am
Contact:

one question about overloading

Post by icepeanuts »

Who would explain why the output for the code below is "double []"?
Thanks.

class Test {
private Test(Object o) {
System.out.println("Object");
}
private Test(double [] arr) {
System.out.println("double []");
}

public static void main(String[] args) {
new Test(null);
}
}

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: one question about overloading

Post by admin »

It is quite simple if you know what is meant by "most specific" method concept. null can be passed to Object as well as double[], but which is more specific?

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 23 guests