CMSC 433 midterm reviewOct 23rd, 2007Check out old 433 exams• Follow exams link from course webpage• previous offerings don't cover the samematerial– if you see a question on material we didn'tcover, ignore it• it isn't relevant to your midterm preparationTesting• JUnit• Mock Objects• Code coverage– statement, branch coverageTCP Sockets, HTTP• ServerSockets, Sockets• HTTPGenericsgiven a non-generic Stack class:– class Stack { int top = -1; Object a[]; Stack(int maxCap) { a = new Object[maxCap]; } Object pop() { Object r = a[top]; a[top--] = null; return r; } void push(Object e) { a[++top] = e; } }• modify it to be a Stack<E>Bounded Wildcards inGenerics• What is the difference between definingsomething as:– Collection<?> c– Collection<Object> c– Collection<? extends E>– Collection<? super E>• Where/when might these be used (e.g.,method parameters, return values)• See "Effective Java Reloaded" slidesBounded type variables• If you need a type that is bound andoccurs in more than one place: <T extends Number> T sum(List<T> x) { ... }Source code version controlDesign patterns• Observer• Decorator• Adapter• VisitorConcurrency andSynchronization• synchronized• wait/notifyAll• java.util.concurrent.**– ReentraintLock– Lock (lock, unlock, tryLock, ...)– Condition (await, signal, signalAll)Concurrency bugs• Data races• atomicity failures• DeadlockGuarding againstconcurrency bugs• Documenting concurrency– GuardedBy annotation•
View Full Document