Académique Documents
Professionnel Documents
Culture Documents
Student ID # _________________________________
Please leave at least one seat between yourself and the person next to you.
No books, notes, or electronic equipment can be used during the exam.
Place your answers inside the provided boxes.
Any CHEATING will result in an F as well as being written-up on academic dishonesty.
Points
Question # Points Earned
Available
1 6
2 6
3 6
4 6
5 6
6 6
7 6
8 6
9 6
10 6
11 6
12 6
13 6
14 6
15 6
16 10
Total: 100
The Rect, ColoredRect, and RoundedColoredRect classes are defined below and compile
without error. They will be used in many of the questions to follow.
Using the classes define on the previous page, how many bytes of memory are reserved on the heap:
Question 2 (6 Points)
The ConstructorTester class below does not compile due to syntax errors inside the main
method. Circle the line numbers, if any, next to those lines of code inside that method that
produce errors.
Question 3 (6 Points)
a) What is the term used to describe GET methods in Object Oriented Programming?
b) What is the term used to describe SET methods in Object Oriented Programming?
The code below compiles and runs without error. What output would result when executed?
Question 5 (6 Points)
The CBV program below compiles and executes without error. What output would result from
running this program?
In lab we did bitwise-AND (‘&’) operations. A bitwise-OR (‘|’) operation works similarly, except
that it performs OR operations between bits rather than AND operations. The code below
compiles and runs without error and uses both. What output would result from running it?
Question 7 (6 Points)
The RectPrinter program below compiles and executes without error. What output results
when running it?
The ATCDriver program below compiles and executes without error. What output results when
running it?
Question 9 (6 Points)
The _______________________________ only cares about an object’s actual type, which is the
In the diagram below we are using the eclipse IDE’s debugger and execution has stopped at a breakpoint
on the highlighted line of code. If one were to press the “Step Over” button, what would the debugger do?
a) Skip execution of the clearAndPrint method and pause on the next line of code.
b) Skip execution of the clearAndPrint method and all following statements until another
breakpoint is reached.
c) Execute the clearAndPrint method and pause on the next line of code.
d) Execute the clearAndPrint method and all following statements until another breakpoint is
reached.
Question 11 (6 Points)
The code below compiles and runs without error. What output would result when executed?
The Op and OpTester classes below compile and run without error. What output would result
from running the OpTester program?
public class Op
{
public static int counterA = 0;
public int counterB = 0;
public Op() {}
What is the name of the java construct (it’s also a Java keyword) that we used in HW 3 for representing
a fixed number of textual choices for a given variable
a) assert
b) const
c) enum
d) interface
e) protected
Question 14 (6 Points)
The Num class below compiles and run without error. What output would result from running the
program?
The What class below compiles, but it has a problem. Upon running the program experiences a
runtime error. Circle the line of code where this error originates, meaning where the
exception error is first thrown.
Below is an equals method that we wish to add to the Num class. It should compare the
equivalence of the num instance variable between objects, but it is missing a few pieces. Fill in
the blanks to complete the method such that it works properly.