HELP!

1. Let a be a 2 dimensional array with 2 rows. What expression will give the correct number of elements that a can hold?

a) a.length

b) 2*a.length

c) a[0].length

d) a[1].length

e) a[0].length+a[1].length

2. Describe what will be the content of the 2D array a after the following code fragment is executed:

int r=3; // number of rows

int c=5; // number of columns

int [][] a = new int[r][c]; // create array a

// Compute a multiplication table:

int i, j;

for( i = 0; i < r; i++)

{ for( j = 0; j < c; j++)

{ a[j] = (i+1)*(j+1); // Build multiplication table

}

}

It would be greatly appreciated.

Thanks,

gp

[739 byte] By [gphelps1a] at [2007-10-2 4:48:17]
# 1
HELP!, is not a subject. Be more descriptive if you want people to take the time to read your question.Use the "code" formatting tags when you post code so it retains its original formatting.
camickra at 2007-7-16 0:52:59 > top of Java-index,Java Essentials,Java Programming...
# 2
1. e)2. 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15
roota at 2007-7-16 0:52:59 > top of Java-index,Java Essentials,Java Programming...
# 3
Thank You,I appreciate it-gp
gphelps1a at 2007-7-16 0:52:59 > top of Java-index,Java Essentials,Java Programming...
# 4

hi,

1)its a.length*a[1].lenght when the array is constructed ie

int a[][] = new int [2][4];

when an array is build at run time ie

int a[][] = new int[2][];

a[0] = new int[3];

a[1] = new int[2];

itsfor(i=0 ; i < a.length ;i++ )

{

for(j=0;j<a.length;j++)

count++;

}

2) u will get compile time error , u cant access two dimensional array as a[j]>

sandeepgna at 2007-7-16 0:52:59 > top of Java-index,Java Essentials,Java Programming...
# 5
> 2) u will get compile time error , u cant access two dimensional array as a[j]He actually wrote a[i][j] but the i got lost because he didn't use code formatting.
roota at 2007-7-16 0:52:59 > top of Java-index,Java Essentials,Java Programming...