You are on page 1of 3

COM1300

Midterm Exam Preview Name:



Scope of material covered on the Midterm:
1. The textbook, chapters 1-5, and Appendix J
2. The lecture slide decks, including the supplemental ones.
3. The videos assigned covering the early Codingbat exercises

4. The assigned Codingbat exercises and related Codingbat help files (less important).
5. Skills learned during your lab assignments

True or False (2 pts apiece, 20 pts total):


The exam may include a few true-false questions that test your grasp of basic facts and concepts. A lot
of these questions are taken directly from the little Concept: boxes in the margins of your textbooks,
and from the list of terms at the end of each chapter. Others are simple facts about Java constructs that
you should have encountered in Lab. Some may also reference specific bullet points on slides.
Examples:
____ A Java array can be sorted in a single Java statement.
____ A mutator method is used to return the value of a field.


Multiple Choice (circle your answer) [2 points apiece, ~10 total]
The exam will contain some multiple choice questions that continue the same topics in the true-false
questions. I may either ask you to pick either the true answer from a list or pick the one false answer
from a list of true ones. I may also ask you to distinguish between statements that are always true
versus statements that are only sometimes true. I may also ask you to tell which Java expression from a
list means the same thing as another Java expression.

Examples:

1. Suppose a and b are Boolean variables. Which one of the following statements does not mean the
same thing as the others?
a. a != b
b. !(a == b)
c. (a && !b) || (b && !a)
d. (a && b) || (!a && !b)

2. Which one of the following data types is not a reference type?
a. Integer
b. int
c. int []
d. ArrayList<Integer>

COM1300 Midterm Preview Page 1



COM1300 Midterm Exam Preview Name:


Fill in the code (3 points each, ~30 total):
In this section of about 10 questions, I ask you to either fill in a few words of code, or I show you some
code and ask you what its value will be. Advice: know your methods for String, ArrayList, HashSet,
HashMap, and Random.

Note: In these problems, any mention of the ordinal numbers (1st , 2nd, 3rd, etc.) follows their normal
English meanings, not Java-specific index values (which start at zero).

Examples:

Gives the position of the last occurrence of the


string s2 within the string s1 (if s2 is present) s1.____________________(s2)
The value of
"mississippi".substring(5, 9) "_______________________"
Java keyword meaning no object at all
_______________________

Short Answer [4 pts apiece, ~20 pts total]:
Other questions ask you to tell what is wrong with each piece of buggy code. The question will tell you
the symptoms of the bug. The bugs are all ones that we have discussed in class at some point:
missing/extra semicolons, missing/illegal return statements, uninitialized fields, local variables that hide
like-named fields, out-of-bounds indexes, calling the wrong methods for the given class, etc. For these
questions, assume that all required imports have been done correctly.

Example:
1. Why does the following method not compile? ____________________________________________
________________________________________________________________

/** Search a list of stories for one containing a specific term */

public String search (ArrayList<String> stories, String term)


{
for (String story: stories) {
if (story.contains(term)) {
return story;
}
}
}

COM1300 Midterm Preview Page 2



COM1300 Midterm Exam Preview Name:

Code Walkthroughs (10 points apiece, 10-20 total):
Expect either one or two short code walkthroughs in table format. Indicate the value of each variable at
the end of each pass through the loop.

1. This program tests part of a famous conjecture in mathematics.


(For fun, can you guess what it means?)

int x = 13; Pass # x


while (x != 1) { start 13
if (x % 2 == 0) { 1
x /= 2;
} 2
else { 3
x = 3 * x + 1; 4
} 5
} 6
7
8
9

COM1300 Midterm Preview Page 3