Forums Register Login

SCJP Chapter 01 Self Test Qn no. 3

+Pie Number of slices to send: Send

Answer:
-> A and E use valid var-args syntax.
My Doubt Is Why "Option B" Is Wrong ??
thanks in advance
+Pie Number of slices to send: Send
Hello rajan,
Option B is not correct. Because If you use it, then at line 3 and 4 will cause compilor error as it couldn't find match. Because doStuff(1) expect a function that takes an integer argument not an integer array argument (except var-args). Same reason for doStuff(1,2).
+Pie Number of slices to send: Send
 

Md. Minhajur Rahman wrote:Hello rajan,
Option B is not correct. Because If you use it, then at line 3 and 4 will cause compilor error as it couldn't find match. Because doStuff(1) expect a function that takes an integer argument not an integer array argument (except var-args). Same reason for doStuff(1,2).



now its clear..thanks alot sir..
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1622 times.
Similar Threads
Gotcha: Varargs spoofs method signature [from Sierra/Bates book]
DOUBT from scjp book
var-args doubt clarification needed
New type of var-args syntax (at least to me)
varargs doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 04:19:37.