• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array reference assignments for multidimensional arrays

 
Ida Achi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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;
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources...
 
Alejandro Liz
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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.
 
mvPrasad Regula
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic