• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Array reference assignments for multidimensional arrays

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A,B,E and F are the correct answers for below. Why are C and D not correct when E is correct??? Please explain to be. Thanks


Given:



Which of the following lines of code could be inserted at line /
and still allow the code to compile? (choose all that apply)

A. b2[1][1] = big;
B. b[1][0] = 3;
C. b2[0][1][]1 = b;
D. b2[0][2][1] = b[1][0];
E. b2[1][1][0][1] = b[1][0];
F. b2[1][1] =b;
 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please QuoteYourSources...
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problems with C is the declaration, because, the number 1 is out of the declaration.
The problem with D is that you are trying to assign a value in a inexistent position in the array b2.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does line #3 work out for you. It should give an error as left of assignment operator is one dimensional array and the right hand side of the assignment operator is 2 dimensional array.
 
Alejandro Liz
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mvPrasad Regula wrote:How does line #3 work out for you. It should give an error as left of assignment operator is one dimensional array and the right hand side of the assignment operator is 2 dimensional array.


yes, I saw that, but a think it was a type error.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic