aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes multi arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "multi arrays" Watch "multi arrays" New topic
Author

multi arrays

saied ims
Ranch Hand

Joined: Jun 21, 2005
Posts: 109
1. public class Test {
2. public static void main(String [] args) {
3. byte [][] big = new byte [7][7];
4. byte [][] b = new byte [2][1];
5. byte b3 = 5;
6. byte b2 [][][][] = new byte [2][3][1][2];
7.
8. }
9. }
which of the following lines of code could be inserted at line 7, and still allow the code to
compile? (Choose four that would work.)
A. b2[0][1] = b;
B. b[0][0] = b3;
C. b2[1][1][0] = b[0][0];
D. b2[1][2][0] = b;
E. b2[0][1][0][0] = b[0][0];
F. b2[0][1] = big;

the answer is a b e f why??? and what is the diffrent between c and e
thanks
Sergei Iakhnin
Ranch Hand

Joined: Nov 09, 2004
Posts: 53
C. b2[1][1][0] = b[0][0];
D. b2[1][2][0] = b;


Since b2 is a 4-dimensional array b2[1][1][0] can be assigned a 1-dimensional array. Since b is a 2-dimensional array b[0][0] is a byte. Thus neither b nor b[0][0] can be assigned to b2[1][1][0].


SCJP 1.4, SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multi arrays