This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is the output for the below code is different? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "What is the output for the below code is different?" Watch "What is the output for the below code is different?" New topic
Author

What is the output for the below code is different?

thejaka samarakoon
Ranch Hand

Joined: Jul 20, 2010
Posts: 56
What is the output for the below code ?



Why in this program int is printed rather than long? Can anyone explain.

rushikesh sawant
Ranch Hand

Joined: Dec 22, 2009
Posts: 65
method with var-arg is selected only if there is no other valid overload. You should read method overloading section.


SCJP 5.0 100%
thejaka samarakoon
Ranch Hand

Joined: Jul 20, 2010
Posts: 56
rushikesh sawant wrote:method with var-arg is selected only if there is no other valid overload. You should read method overloading section.
thanks
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Var - args is added to Java in JDK 1.5, but widening is there long before, so they did like this. Widening > Boxing > Var - Args. This is the priority order!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the output for the below code is different?
 
Similar Threads
Casting int to long
Question from New Boone
about specific method and compile time type error
help me in kicking off the bug from the following code
Polymorphism question