aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question 9 from Examlab practice exam 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question 9 from Examlab practice exam 1" Watch "Question 9 from Examlab practice exam 1" New topic

Question 9 from Examlab practice exam 1

Henry Dai

Joined: Feb 27, 2009
Posts: 10

Hi, all , i have a question on var-arg. why line#1 invoke method 2 instead of method 5. Isn't that var-arg will be last considered? int[] is also an object, why it didnt choose method 5 over method 2. Could someone please explain, thank you!
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885

var-arg parameters can accept arrays too. For an array argument, a var-arg parameter is more appropriate, other than passing it to a parameter with java.lang.Object type.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
I agree. Here's the link:
subject: Question 9 from Examlab practice exam 1
Similar Threads
Please Explain this Constructor parameter type ?
Why does this method call compile with only one argument ?
ExamLab: This snippet compiles, but the other one doesn't. Why?
5 Golden Rules of widening, boxing & varargs