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

Cornell net id ____________________ Name ________________________________CS 100J Prelim 2 17 March 2005This 90-minute exam has 6 questions (numbered 0..5) worth a total of100 points. We suggest that you spend a few minutes looking at allquestions before beginning so that you can see what is expected.Budget your time wisely. Use the back of the pages, if you need morespace.Question 0 (2 points).Write your netid and your name, legibly, at thetop 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 booleanexpression that evaluates to truewhen variable xis an instance ofclass Car, falseotherwise.0 ___________ out of 021 ___________ out of 102 ___________ out of 203 ___________ out of 214 ___________ out of 245 ___________ out of 23Total ________ out of 100

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

Cornell net id ____________________ Name ________________________________Question 2 (20 points).Write a complete class MySumthat contains a static functionsumIntegerthat returns the sum of the Integers in its parameter Vectorv. You can assume that vis not null. MySumshould contain only one thing: the static method.Please write a complete classand comments (javadoc and coding comments).Elements of the Vector can be of any class, however, function sumIntegershould sum up onlythe Integers in the Vector and return the sum as an int. Examples: Below, we use ? for the valueof 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.

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.