wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array reference assignments for multidimensional arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array reference assignments for multidimensional arrays" Watch "Array reference assignments for multidimensional arrays" New topic
Author

Array reference assignments for multidimensional arrays

Ida Achi
Greenhorn

Joined: Oct 02, 2009
Posts: 25

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

Joined: Aug 03, 2008
Posts: 9303
    
  17

Please QuoteYourSources...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Alejandro Liz
Greenhorn

Joined: Sep 26, 2009
Posts: 6
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.


SCJP 78%, and looking for the next certification
mvPrasad Regula
Ranch Hand

Joined: Sep 14, 2009
Posts: 42
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.


Prasad Regula
Alejandro Liz
Greenhorn

Joined: Sep 26, 2009
Posts: 6
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.
 
subject: Array reference assignments for multidimensional arrays