• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Mock Question - Array

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the value of size when you pass it to this method ?
 
Mukti Bajaj
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
There is no size value mentioned.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look closly he says the size is 4 try it now and seeifyou get the answer
 
Tejas Nakawala
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got the exam Mukti.
Thankx again,
Keep in Touch,
Tejas Nakawala
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic