aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overloading (was what 'll be output) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overloading (was what Watch "Overloading (was what New topic
Author

Overloading (was what 'll be output)

prashantK Singh
Greenhorn

Joined: Sep 11, 2006
Posts: 19
hello everybody
will some body tell me what'll be the output of this prog

class Eggs {
int doX(Long x, Long y) { return 1; }
int doX(long... x) { return 2; }
int doX(Integer x, Integer y) { return 3; }
int doX(Number n, Number m) { return 4; }

public static void main(String[] args) {
new Eggs().go();
}
void go() {
short s = 7;
System.out.print(doX(s,s) + " ");
System.out.println(doX(7,7));
}
}

[ September 11, 2006: Message edited by: prashantK Singh ]
[ September 11, 2006: Message edited by: Barry Gaunt ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
4 3
This problem comes from the K & B SCJP 5.0 book - what did you not understand from the explanation that they provided?
[ September 11, 2006: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Overloading (was what 'll be output)
 
Similar Threads
boxing
boxing ,widening,var-args
varargs doubt
Question on widening ,boxing
K&B Mock Question 5