• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Array

 
Karthikeyan Varadarajan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Opps,

I got the idea. I read the question wrongly.

THanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic