• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K&B Mock Exam Question

 
Anthony Zepezauer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I have to be missing something here but I've gone over and over it and just can't see it. Here's a question from the mock exam on the CD that came with K&B (line numbers added by me):



I selected the "Does not compile" option, because:

* line 11 is calling a no-args constructor;
* there is a constructor with args defined on line 6, therefore there will be no default constructor supplied;
* no no-args constructor is explicitly defined.

But I was wrong, I tried it and this code does compile and run. What am I missing??? Any help is appreciated.

[ November 09, 2007: Message edited by: Anthony Zepezauer ]
[ November 09, 2007: Message edited by: Anthony Zepezauer ]
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"No arguments" is a valid value for a varargs parameter. The constructor will simply be called with an array of length 0.
 
Anthony Zepezauer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohhhhh. Thanks Kelvin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic