prelim2fall2005 - Cornell net id _ Name _ CS 100J Prelim 2...

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

View Full Document Right Arrow Icon
Cornell net id ____________________ Name ________________________________ CS 100J Prelim 2 18 October 2005 This 90-minute exam has 6 questions (numbered 0. .5) worth a total of 100 points. 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. // {y is sum of 1. .k–1} y = ; // {y is sum of 1. .k+1} (c) Write a boolean expression that evaluates to true when variable b is an instance of class Employee , 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
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 ________________________________ Question 2 (20 points). Write a complete class MyCount that contains a static function howMany that returns how many Integers in its parameter Vector v are 0 . Assume that v is not null . Class MyCount should contain only one thing: the static function. Put a suitable javadoc specification on the function. The elements of Vector v can be any type of object. Function howMany should count how many of v ’s elements are of class Integer and contain the integer 0 and return that number as an int . Examples: Below, we use ? for the value of an
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.

Page1 / 6

prelim2fall2005 - Cornell net id _ Name _ CS 100J Prelim 2...

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