CS 177 Spring 2005 Exam I



CS 180 Fall 2005 Final Exam

There are 40 multiple choice questions. Each one is worth 2 points. There are 6 programming questions. Each one is worth 20 points.

Answer the multiple choice questions on the bubble sheet given and the programming questions on the exam booklet.

Fill in the Instructor, Course, Signature, Test, and Date blanks. For "Instructor" put your Recitation Instructor's last name. For "Course" put CS 180. For "Test" put Final.

08:30 recitation in REC 122: Matt Carlson

08:30 recitation in BRNG B254: Andy Scharlott

09:30 recitation in BRNG B268: Nick Sumner

11:30 recitation in REC 308: Rimma Nehme

01:30 recitation in UNIV 103: Alvin Law

Fill in the bubbles that correspond to your name, section and student ID in the bubble sheet. For your section number, use 0830, 0930,1130, or 0130 -- based on the start time of your Friday recitation.

For your student ID, use the 10 digit ID number on your student ID card. DO NOT USE YOUR SOCIAL SECURITY NUMBER!

Exams without names will be graded as zero. Only the answers on the bubble sheet will be counted. The questions will be discarded.

For the programming questions create a Java class that would compile without error. Comments are nice, but are not required.

Recitation Start Time: _________________________________

Student Last Name: __________________________________

Student First Name: __________________________________

Multiple Choice Questions (2 points each):

1. Which of the following statements regarding Java is false?

a. Java uses a compiler

b. A Java program compiles into machine language

c. Java uses an interpreter

d. Java is a programming language

2. Which of the following is a legal variable name in Java?

a. 1stInput

b. long

c. NumberOfPlayers

d. player.1

3. What is the output produced by the following code?

int n = 2;

System.out.print((++n) + " " + (n++) + "\n");

System.out.println(n);

a. 2 3 4

b. 3 3 4

c. 3 3

4

d. 2 3

4

4. What is the output produced by the following code?

String temp = "Hello CS180 Class";

System.out.print(temp.substring(8).trim());

a. 180Class

b. 180 Class

c. Hello CS

d. Nothing - this causes a compiler error

5. In a Java program, you read the following statement that compiles and executes.

Cookie cookie = new Cookie("chocolate chips");

What can you conclude?

a. Cookie is the name of a class.

b. cookie is a primitive type variable.

c. The Cookie class must have a constructor that has one formal parameter of type String.

d. a and c

6. Which of the following while loops is equivalent to the do-while loop? Hint: you may want to draw a flow chart to figure out the answer.

do

{

y = x + 7;

x++;

} while (x < 9);

a. y = x + 7;

x++;

while (x < 9)

{

y = x + 7;

x++;

}

b. while (x < 9)

{

y = x + 7;

x++;

}

y = x + 7;

x++;

c. while (x ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download