• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array Question

 
Matt Ghiold
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is from JQ+
Which of the following correctly declare a variable which can hold an array of 10 integers?
Answers:
1. int[] iA
2. int[10] iA
3. int iA[]
4. Object[] iA
5. Object[10] iA
JQ+ says the answer is 1 and 3
I though 2 was the correct answer, can someone please explain this to me.
Thanks,
-Matt
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to watch the semantics on the test. I passed mine in December with an 86% and am sure that I didn't get my goal of above 90% because of questions like this.
The key here is an array that "can" hold 10 not "must" hold 10. Of course in order for this to actually hold 10 ints you would have to follow up with:

or

Hope this helps.
 
Matt Ghiold
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhh, I get it thank's so much!
-Matt
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
And just to point out the obvious...
Option number 2 wouldn't even compile - no matter what you were to follow it up with.
Good Luck,
-Dirk Schreckmann
[ March 04, 2002: Message edited by: Dirk Schreckmann ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot to mention that yesterday! Good point.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic