prelim2spring2006

prelim2spring2006 - Cornell net id Section day Name Section...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Cornell net id ____________________ Name ________________________________ Section day ______________________ Section time ___________________________ CS 100J Prelim 2 16 March 2006 Have a good break!!! This 90-minute exam has 6 questions (numbered 0. .5) worth a total of 100 points. Spend a few minutes looking at all ques- tions before beginning. Use the back of the pages, if you need more space. Question 0 (2 points). Fill in the information, legibly, at the top of each page (Hint: do it now.) Question 1 (10 points). (a) Consider the call C.m(5) on the following static method m , declared in class C . public static void m( int p) { for ( int k= 0; k != p; k= k+1) { int x= p*k; p= p + x; } } (a1) When is p created during execution of the call? (a2) When is k created during execution of the call? (a3) When is x created during execution of the call? (b) Below, fill in the assignment so that the following assertion is true —i.e. if execution starts with assertion P true, then after the assignment to y , R is true. Be careful. // { P: y is the sum of h..100 } y = ; // { R: y is the sum of ( h–1). .101 } (c) State the four loopy questions used to develop a loop. 0 ___________ out of 02 1 ___________ out of 10 2 ___________ out of 15 3 ___________ out of 14 4 ___________ out of 22 5 ___________ out of 37 Total ________ out of 100
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Cornell net id ____________________ Name ________________________________ Section day ______________________ Section time ___________________________ Question 2 (15 points). At the bottom of the page are definitions of three classes: Animal , Cat , and Dog . Assume that these three statements have been executed: Animal a= new Cat("A", 1); Cat c= new Cat("C", 2); Dog d= new Dog("D", 3); Write the value of each expression given below; if one leads to an error, write "ERROR". It may help you to draw the objects that are created by execution of the three statements above. (2a) c.isOlder(a);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '07
  • FAN/VANLOAN
  • Sierpinski carpet, Cornell net id, ________________________________ Section time, Section time ___________________________

Page1 / 6

prelim2spring2006 - Cornell net id Section day Name Section...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online