Name: ___________________________________________________
Umail Address: ______________________________@ umail.ucsb.edu
Discussion section (Circle one:) 6:30pm 7:30pm
Please write your name only on this page.
That allows me to grade your exams without knowing whose exam I am grading.
This exam is closed book, closed notes, closed mouth, cell phone off,
except for:
There are 100 points worth of questions on the exam, and you have 75 minutes to complete the exam.
A hint for allocating your time—on your first pass through the exam:
If you do that, after you complete your first pass through the exam in 50 minutes, you'll still have 25 minutes to:
We've also discussed two areas in memory:
In the table on the next page, there is a row for each "thing" that can be in memory. There is a column for stack, and a column for heap. There is also a space for you to fill in some code in a Java class with a main program.
For each of the entries in the table, consider whether that "thing" can end up in that area of memory (either stack or heap).
Circle one: |
||
(2 pts) A primitive variable can be nested inside an object instance | True |
False |
(2 pts) A reference variable can be nested inside an object instance | True |
False |
(2 pts) An object instance can be nested inside another object instance | True |
False |
(2 pts) A reference may refer to a primitive variable | True |
False |
(2 pts) A reference may refer to another reference | True |
False |
(2 pts) A reference may refer to an object instance | True |
False |
(See instructions for problem 1 on previous page)
public class Example { |
} // end class |
heap | |||
---|---|---|---|
stack | |||
primitive | reference | object instance |
public int getPrice();
and as such, there needs to be some generic type for tools.public void consume( _____ item);
where the blank needs to be filled in with some kind of type that represents a food or drink in general.
public void addToPack(_______ thing) throws WontFitInPackException;
where the blank needs to be filled in with some kind of type that represents a thing that can be added to a backpack.continued from previous question...
WontFitInPackException
that can be thrown whenever a player tries to add something to a backpack, but that new item won't fit. // auto-boxing
// auto-unboxing
Total points: ?