• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in Array

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Opps,

I got the idea. I read the question wrongly.

THanks a lot
reply
    Bookmark Topic Watch Topic
  • New Topic