jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array Dimensions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array Dimensions " Watch "Array Dimensions " New topic

Array Dimensions

sonali sawant

Joined: Oct 24, 2005
Posts: 13
Given the following,
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];
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;

answer is A,B,E,F

can anyone explain array dimensions here?
Jon Lee
Ranch Hand

Joined: Mar 04, 2005
Posts: 134
A OK. Both are two dimensions array;
B OK. Both are byte primitives;
C Not OK. Left is one dimension array, but right is a byte primitive;
D Not OK. Left is one dimension array, but right is two dimensions array;
E OK. Both are byte primitives;
F OK. Both are two dimensions array;

SCJP 5.0 - 98% (2007)<br />SCWCD 1.4 - 97% (2007)
I agree. Here's the link: http://aspose.com/file-tools
subject: Array Dimensions
Similar Threads
Self Test Question on Arrays by Kathy's Book
Array confusion
Array Reference Assignments
scjp1.4 qtn on Mult-dimensional array