• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Doubt in Array  RSS feed

 
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 ?
 
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!