Please don't. Exam is closed-book, closed-notes, and individual work. | CSCI A201/A597/I210 Second Midterm Examination Spring Semester 2003 |
All correct
answers are worth exactly one point. Leaving a question unanswered will count
as a zero. There is no penalty for guessing. DO NOT MARK more than one answer
for each question.
The test is closed-book and closed-notes.
Good luck and do well!
| 1. You compile and run the following program. What does it print? | |
|
|
2. Consider the following condition.
Which of the following represents a simplification of it (obtained perhaps using DeMorgan).! (x % 3 != 0 || x % 2 != 0) | |
| |
3. Assume a is of type boolean and consider the following condition.
Which of the following represents a simplification of it.(a && !a) == false | |
| |
4. Consider the following program fragment.
What value does y have at the end?int x = 1, y = 1; if (x < 2) if (x > 1) y = 2; else y = 3; else y = 4; | |
| |
5. Consider the following program fragment.
What value does y have at the end?int x = 1, y = 1; if (x > 2) y = 2; y = y + 1; else y = y + 1; | |
| |
6. Consider the following program fragment.
What value does y have at the end?
| |
| |
7. Consider the following program fragment.
What value does y have at the end?int x = 1, y = 1; if (x < 2) y = 2; else y = y + 1; y = y - 1; | |
| |
8. How many question marks will be printed by the following code fragment?
| |
| |
9. How many question marks will be printed by the following code fragment?
| |
| |
10. How many question marks will be printed by the following code fragment?
| |
| |
11. Consider the following fragment. What does it print?
| |
| |
12. Consider the following fragment. What does it print?
| |
| |
13. Consider the following fragment. What does it print?
int[] v = new int[10]; for (int i = 0; i < 10; i++) v[i] = i % 3; System.out.print(v[3] + v[5]); | |
| |
14. Consider the following fragment. What does it print?
| |
| |
15. Consider the following program. What does it print?
| |
| |
16. Consider the following program fragment. What would it print?
| |
| |
17. Consider the following program fragment. What would it print?
| |
| |
18. Consider the following program fragment.
What's needed for the output to resemble an Z?
| |
| |
19. Consider the following code fragment, what does it print?
String seven = "eleven"; System.out.println(seven.substring(0, 3)); | |
| |
20. Consider the following code fragment, what does it print?
| |
| |
21. Consider the following code fragment, what does it print?
| |
| |
22. Does this source code compile?
| |
| |
23. Does this source code compile?
| |
| |
24. Does this source code compile?
| |
| |
25. Does this source code compile?
| |
| |
26. If you compile and run this code, what is the output?
| |
| |
27. If you compile and run this code, what is the output?
| |
| |
28. What gets printed when you compile and run the following program?
| |
| |
29. What gets printed when you compile and run the following program?
| |
| |
30. What does the next fragment print if embedded in a complete program?
String two = "to".charAt(0) + "two".charAt(1) + "ew"; System.out.println(two); | |
| |
31. What does mix("abc", "def") return if mix
is defined as below?
| |
| |
32. What does mix("abc", "def") return if mix
is defined as below?
| |
| |
33. What does mix("abc", "def") return if mix
is defined as below?
| |
| |
34. Assuming that the following program fragment is syntactically correct...
int[] a = new int[10]; ... a[0] = fun(a[2], a); | |
... select the correct header for method fun.
| |
35. Assuming that the following program fragment is syntactically correct...
int[] a = new int[10]; ... a = fun(a[1], a); | |
... select the correct header for method fun.
| |
36. Assuming that the following program fragment is syntactically correct...
int[] a = new int[10]; ... a[0] = fun(a, a); | |
... select the correct header for method fun.
| |
A201/A597/I210 Second Midterm Exam Makeup Thu Apr 24 2003 in RH100