Docsity

Unsolved Exam #1 - Introduction to Programming | CS 1110, Exams of Computer Science

Toggle sidebar
bg1
CS 101 Exam 1 Spring 200 Email Id ___________ Name ______________________________________
Pledged Page 1 of 6
This exam is open text book and closed notes. Different questions have different points associated with them
with later occurring questions having more worth than the beginning questions. Because your goal is to maxi-
mize your number of points, we recommend that you do not dwell too long on any particular question during
your first pass through the exam.
When an integer type is required use int; when a floating point type is required use double.
Page 1 ______ / 3
Page 2 ______ / 21
Page 3 ______ / 21
Page 4 ______ / 16
Page 5 ______ / 29
Page 6 ______ / 10
Total ______ /100
Pledge:
1. (3 points) What section of CS101 are you in?
_______ 2 CS101E _______ 7 1400-1515 Thursday
_______ 3 0800-0915 Thursday _______ 8 1530-1645 Thursday
_______ 4 0930-1045 Thursday _______ 9 1700-1815 Thursday
_______ 5 1100-1215 Thursday _______ 10 1830-1945 Thursday
_______ 6 1230-1345 Thursday _______ 11 2000-2115 Thursday
pf3
pf4
pf5

Partial preview of the text

Download Unsolved Exam #1 - Introduction to Programming | CS 1110 and more Exams Computer Science in PDF only on Docsity!

This exam is open text book and closed notes. Different questions have different points associated with them

with later occurring questions having more worth than the beginning questions. Because your goal is to maxi-

mize your number of points, we recommend that you do not dwell too long on any particular question during

your first pass through the exam.

When an integer type is required use int; when a floating point type is required use double.

Page 1 ______ / 3

Page 2 ______ / 21

Page 3 ______ / 21

Page 4 ______ / 16

Page 5 ______ / 29

Page 6 ______ / 10

Total ______ /

Pledge :

1. (3 points) What section of CS101 are you in?

_______ 2 CS101E _______ 7 1400-1515 Thursday

_______ 3 0800-0915 Thursday _______ 8 1530-1645 Thursday

_______ 4 0930-1045 Thursday _______ 9 1700-1815 Thursday

_______ 5 1100-1215 Thursday _______ 10 1830-1945 Thursday

_______ 6 1230-1345 Thursday _______ 11 2000-2115 Thursday

2. (3 points) What is the value of the following expression?

3. (3 points) What is the value of the following expression?

4. (3 points) What is the value of the following expression?

5. (3 points) What is the value of the following expression?

6. (3 points) Write a single statement that defines a floating point variable x whose initial value is 32.64.

7. (3 points) Suppose n and m are previously defined and initialized integer variables. What type of statement is

n = m;

8. (3 points) Suppose n and m are previously defined and initialized integer variables. What happens to n in statement

n = m;

16. (4 points) What method is defined in every Java application program?

17. (4 points) Write a Java comment stating that there are 10 kinds of people.

Consider the following class definition in questions 18 through 20.

public class C { private int number; public C() { number = 0; } public C(int n) { number = n; } public void set(int n) { number = n; } public int get() { return number; } public String toString() { String result = "C: (" + number + ")โ€; return result; } }

18. (4 points) How many constructors does the class C definition provide?

19. (4 points) List the name(s) of the accessors (inspectors) provided by the class C definition.

20. (4 points) List the name(s) of the instance variables (attributes) provided by the class C definition.

21. (5 points) Write a single statement that displays to standard output the message There are 10 kinds of people.

22. (5 points) Write a single statement that defines a Scanner variable stdin associated with the standard input stream.

Your definition must be compatible with the latest version of Java.

23. (5 points) Write a single appropriate statement that prompts the user to provide the ambient temperature. For your

information, the associated input will be used as an integer Celsius value.

24. (5 points) Using a previously defined Scanner variable stdin associated with the standard input stream, write a sin-

gle statement that defines and initializes an integer variable ambient with the next integer input value from standard

input.

25. (5 points) What is the value of a Line variable line1 after the following statement completes?

Line line1 = new Line();