[Logo]
Forums Register Login
Mock Question - Array
Hi,
int[][] makeArray( int size)
{ int[][] triArray = new int[size] [];
int val=1;
for( int i = 0; i < triArray.length; i++ )
{ triArray[i] = new int[i+1];
for( int j=0; j < triArray[i].length; j++ )
{ triArray[i][j] = val++;
}
}
return triArray;
}
a) 1 2 3 4
5 6 7
8 9 10
b) 1 4 9 16
c) 1 2 3 4
d) 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
e) 1 2 3
4 5 6
7 8 9 10
What can be the possible answer of the above code??
Can somebody explain.
Thanks.
Mukti
what is the value of size when you pass it to this method ?
Hi,
There is no size value mentioned.
Hi Mukti,
Will u pls tell me from which mock exam u have taken this question pls provide link.
Thankx,
Tejas
Hi,
http://www.javaranch.com/maha/_Mock_Exams/MindQ_s_Sun_Certified_Java_Programmer_Practice_Test.htm
This is link for the mock question given above.
Mukti
Look closly he says the size is 4 try it now and seeifyou get the answer
Got the exam Mukti.
Thankx again,
Keep in Touch,
Tejas Nakawala

This thread has been viewed 1006 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 24, 2018 20:48:26.