File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes varargs doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "varargs doubt" Watch "varargs doubt" New topic

varargs doubt

tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
this is a self test question from pg-79 of K&B book

question is :

given choice for answer :

the answer given is A & E.

i think the answer should be only E because each method has argument " 1" so 1st argument is fixed . morever option A takes a number of arguments but option E takes the first argument that is same in both methods { i.e 1 } & then any number of arguments.

am i misinterpreting something or is it right ? if right explain

Do Right , Fear No Man
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

Varargs accepts zero(0) or more number of arguments (0,1,2 etc...). Now can you understand the reasoning for the given answer?

[How to ask questions] [Twitter]
I agree. Here's the link:
subject: varargs doubt
It's not a secret anymore!