{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

prelim2spring2005

# prelim2spring2005 - Cornell net id Name CS 100J Prelim 2 17...

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

Cornell net id ____________________ Name ________________________________ CS 100J Prelim 2 17 March 2005 This 90-minute exam has 6 questions (numbered 0..5) worth a total of 100 points. We suggest that you spend a few minutes looking at all questions before beginning so that you can see what is expected. Budget your time wisely. Use the back of the pages, if you need more space. Question 0 (2 points). Write your netid and your name, legibly, at the top of each page (Hint: do it now). Question 1 (10 points). Answer the following questions briefly (a) What is a loop invariant? (b) Fill in the assignment so that the following assertion is true. // {x is sum of 1..k} x= ; // {x is sum of 1..k+2} (c) Write a boolean expression that evaluates to true when variable x is an instance of class Car , false otherwise. 0 ___________ out of 02 1 ___________ out of 10 2 ___________ out of 20 3 ___________ out of 21 4 ___________ out of 24 5 ___________ out of 23 Total ________ out of 100

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

View Full Document
Cornell net id ____________________ Name ________________________________ Question 2 (20 points). Write a complete class MySum that contains a static function sumInteger that returns the sum of the Integers in its parameter Vector v . You can assume that v is not null . MySum should contain only one thing: the static method. Please write a complete class and comments (javadoc and coding comments). Elements of the Vector can be of any class, however, function sumInteger should sum up only the Integers in the Vector and return the sum as an int . Examples: Below, we use ? for the value of an Object that is not of class Integer. For an object that is of class Integer, we use the integer.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern