aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Question 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 "Array Question" Watch "Array Question" New topic
Author

Array Question

Matt Ghiold
Ranch Hand

Joined: Feb 24, 2002
Posts: 213
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


-Matt<br /> SCJP2<br /> SCJD
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Matt Ghiold
Ranch Hand

Joined: Feb 24, 2002
Posts: 213
Ahhh, I get it thank's so much!
-Matt
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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 ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Forgot to mention that yesterday! Good point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Question