wood burning stoves 2.0*
The moose likes Mock Exam Errata and the fly likes Mock Question - Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Mock Question - Array" Watch "Mock Question - Array" New topic
Author

Mock Question - Array

Mukti Bajaj
Ranch Hand

Joined: Dec 11, 2000
Posts: 59
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
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
what is the value of size when you pass it to this method ?


Val SCJP <BR>going for SCJD
Mukti Bajaj
Ranch Hand

Joined: Dec 11, 2000
Posts: 59
Hi,
There is no size value mentioned.
Tejas Nakawala
Ranch Hand

Joined: Jan 04, 2001
Posts: 80
Hi Mukti,
Will u pls tell me from which mock exam u have taken this question pls provide link.
Thankx,
Tejas
Mukti Bajaj
Ranch Hand

Joined: Dec 11, 2000
Posts: 59
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
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
Look closly he says the size is 4 try it now and seeifyou get the answer
Tejas Nakawala
Ranch Hand

Joined: Jan 04, 2001
Posts: 80
Got the exam Mukti.
Thankx again,
Keep in Touch,
Tejas Nakawala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Mock Question - Array
 
Similar Threads
2 dimension array, great example
Arrays...
Expalin the answer -- Arrays
How to solve
struct in java