Exam #3
Exam #3 is tied with the Final Exam.
Format
This will be your typical short-answer, fill-in-the-blank, true-false, multiple-choice test. It'll probably be worth between 65 and 100 points.
Interesting Questions
The "Standard" column lists topics and sample questions which I expect everyone to know; my plan is that a majority of the test (80% or more) will cover this material.
The "Bonus" column is advanced material, some of which we might not have covered. Some of it will be on the test, but don't bother studying it if you haven't studied the "standard" material first.
"CYU" refers to the "Check Your Understanding" sections of the book.
Topic | Standard | Bonus |
---|---|---|
Control Flow (Chapter 6) |
|
|
Data Types (Chapter 7) |
|
|
OOP | Review the strategy pattern. | Why does Java require an explicit interface and Ruby does not? |
Memory Mapping Objects
This question combines several topics I find fairly important which the book doesn't quite stress enough (at least not in the exercises):
- Memory layout of records/structs/variant-records/class-objects.
- Memory layout and use of virtual method tables.
- What is the different (in terms of VMTs) for class and interface inheritance in Java? It's the same difference between VMTs in C++ and Ruby.
The source code for the CITkit library is available in the JAR file you've been using. If you open up the library in the Package Explorer in Eclipse, you can double-click on a class to see the source code.
Use the source code for IntegerETIR
and
OperatorETIR
to create memory maps for these
instances:
IntegerETIR i = new IntegerETIR(12); IntegerETIR j = new IntegerETIR(99); ExpressionTIR o = new OperatorETIR(i, Operator.ADD, j);
Indicate at the lowest memory level how these variables and the
objects they refer to are mapped out in memory on a 32-bit machine
(int
s and pointers/references are all 32-bits). You
need to map out the objects themselves and their virtual method
tables.
If one object refers to another object, map out that other object.
- What happens when
i.accept(interpreter)
is invoked? What happens wheno.accept(interpreter)
is invoked? How are these similar to each other? How are they different? - What happens when
i.toString()
is invoked? What happens wheno.toString()
is invoked? How are these similar to each other? How are they different? - Is invoking
accept(...)
ortoString()
more efficient? Justify your answer. - How does your picture and answers change when these are implemented in JavaScript?