Sample Questions: Give an example of how Java supports encapsulation. How do Java interfaces support abstraction? What is the primary purpose of the StringBuffer class? Why would you want to override the Object.equals() method? Give a simple example which uses the Singleton pattern. When and why would you consider using the Observer/Observable (Publish/Subscribe) Pattern? When should you create and throw an exception in order to indicate that an error has occurred? What is wrong with the following code? public void f(Graphics g, Image i) { try { i.drawOn(g); } catch (NullPointerException e) {} } What is the difference between the dynamic (actual) type of an object and the static type known by the Java compiler? Why is substitutability desirable? How does Design by Contract help keep modules loosely coupled? How are the Map interface and Sorted Map interface related? Is one substitutable for the other? What secret do Iterators hide? Why are there two types of Map classes (HashMap and TreeMap)? What pattern are AWT Listeners an example of? What is wrong with the following code? (Assume that the "..." represents some type of closable input stream, that is, a file or a socket.) public void g() { BufferedReader in = new BufferedReader(...); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); } in.close(); }