prelim2spring2005

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

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
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 06/01/2008 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

### Page1 / 6

prelim2spring2005 - Cornell net id _ Name _ CS 100J Prelim...

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

View Full Document
Ask a homework question - tutors are online