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

Doubt in Array

Karthikeyan Varadarajan
Ranch Hand

Joined: Jul 04, 2002
Posts: 98
Hi

I found this question in one of the mocks.



Options

Select 1 correct option.

A.1, 3
B.4, 5
C.2, 3
D.1, 2, 3
E.2

I think the correct answer is A. but in that exam it mentioned as E.

Can any one explain, how the E is correct ?


~With Smile<br />VK
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Answer 'A' cannot be correct, as each "subarray" only has three elements (the maximum array index will be 2). So cA[2][3] will throw an ArrayIndexOutOfBoundsException. Answer 'E' (which points to option #2) initializes an array of three char arrays, then initializes each subarray with four elements (with a maximum array index of 3), so cA[2][3] will have a char value of 0.

Hope this helps.
[ June 27, 2005: Message edited by: Steve Morrow ]
Karthikeyan Varadarajan
Ranch Hand

Joined: Jul 04, 2002
Posts: 98
Opps,

I got the idea. I read the question wrongly.

THanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Array