Attention!

Check Piazza for more information regarding the assignments listed here

Assignment 0

Get familiar with the IDE and the submission process. Watch the intro video here. Accept the assignment here.

Released January 10

Due January 21

Assignment 1

Explain all methods that can be reached at a callsite due to inheritance and dynamic dispatch.

Download the specification here. Watch the intro video here. Accept the assignment here.

A note about the intro video: Prof. Pina uses the getMethodsByName method to check whether a method is defined in a class. For the full solution, you’ll probably want to use getMethodsBySignature instead – it does something similar, but lets you specify the method arguments as well as the name, which will save you some trouble in postprocessing the results.

Released January 26

Due February 11

Assignment 2

Inspect and modify fields of a given object using Java reflection.

Download the specification here. Watch the intro video here. Accept the assignment here.

Released February 16

Due February 27 at 11:59 PM

Midterm Exam

The midterm exam will be in class on Tuesday, March 7th. It will cover the material from the first 7 weeks of the class, namely:

  • Principles of software design: modularity, abstraction, refinement, incrementality, encapsulation
  • Objects: definitions, first-class values, identity and equality, dynamic dispatch
  • Object orientation: inheritance, aggregation, overloading and overriding, subtyping, static vs. dynamic types, access modifiers
  • Multiple inheritance: diamond problem and its solutions, interfaces, abstract classes
  • Casting: upcasts and downcasts, static and runtime checks, type coercions
  • Reflection: reification, the Class class, accessing fields and methods through reflection
  • Exceptions: alternatives, try-catch, finally, stack unwinding, checked and unchecked exceptions, throws, errors

A sample midterm is available.

Assignment 3

Use Java stream operations to process data.

Download the specification here. Accept the assignment here.

Released March 14

Due March 31 at 11:59 PM

Assignment 4

Add object-oriented expressions to the interpreter seen in class.

Released April 4

Due April 21 at 11:59 PM

Download the specification here. Watch the intro video here. Accept the assignment here.

A note about the intro video: there are a few tweaks to the interpreter infrastructure since Fall 2021. As an example, Prof. Pina creates an Interpreter instance inside his solution and calls its eval method instead of calling a static Interpreter.evaluate, and switches on the string name of the expression class instead of using instanceof. When you notice discrepancies between the video and the way we did things in class, it’ll usually be easier to do things the way we did them in class. Also, note that “Lecture 17” in the video refers to the lecture we did on 4/4.

Final Exam

The final exam will be 8-10 AM on Friday, May 5th in TBH 180G, our usual classroom. It will cover the material from the second half of the class, namely:

  • Generics: motivation, vs. data structures on Object, type parameters, C++ templates, type constraints
  • Streams and stream programming: immutability, lambda expressions, terminal and non-terminal operations, vs. imperative programming
  • Interpreters: host and guest language, expressions, values, variables and environments, function calls
  • Object representation: metadata, storing fields, vtables and itables, dynamic dispatch
  • Bytecode: the Java Virtual Machine, stack machines, bytecode instructions
  • JIT compilation: performance tradeoffs, hot code, optimizations

We didn’t get to garbage collection, so it won’t be on the final; please ignore it on the sample final.

A sample final is available.