Topics for Exam 1 in Com S 362 This exam covers topics from homeworks 1 and 2. REMINDERS This test is open book and notes. However, it is to be done individually and you are not to exchange or share materials with other students during the test. If you need more space, use the back of a page. Note when you do that on the front. This test is timed. We will not grade your test if you try to take more than the time allowed. Therefore, before you begin, please take a moment to look over the entire test so that you can budget your time. For diagrams and programs, clarity is important; if your diagrams or programs are sloppy and hard to read, you will lose points. Correct syntax also makes some difference. READINGS Read chapters 1-2 of Ken Arnold, James Gosling, and David Holmes's book, The Java Programming Language Third Edition (Addison-Wesley, Reading, Mass., 2000). If you are new to Java you might also want to read the interesting (to you) parts of the "new to Java" section on-line at http://developer.java.sun.com/developer/onlineTraining/new2java/ Also read chapters 1-2 (although you can skim chapter 1) of Arthur J. Reil's book Object-Oriented Design Heuristics (Addison-Wesley, Reading, MA, 1996). If you have more time, you might want to read further in the Java Programming Language Third Edition book; see also the syllabus for further readings. TOPICS Topics marked + below are more important than topics marked - below. Topics marked with ++ are almost certain to be on the test. In general, things that are more like the homework will be more important. * Object Orientation + Explain the features of object-oriented (OO) languages like Java that make it easier to cope with change, and give examples to illustrate these ideas. - What are the disadvantages of OO programming techniques? - For what kinds of programming projects would OO techniques not be needed? * Running Java - Be able to manipulate the CLASSPATH and/or Eclipse to run Java programs. - Be able to explain the connection between packages and directories in file-system implementation of Java. * Objects and Classes + Be able to read Java code that defines an abstract data type (ADT). + Give the output of simple Java programs using instance and static variables, and instance and static methods. + Be able to give the output of simple Java programs that use exceptions. + Be able to explain what statements or expressions violate Java's privacy rules. This includes understanding packages and default privacy in Java. - Be able to diagnose violations of Reil's heuristics for Java class that define ADTs, as found in chapter 2 of his book. + Be able to give the Java interface that corresponds to a Java class. ++ Be able to write code that does file I/O in Java, especially reading and writing strings from files. [HW1] ++ Be able to throw and catch exceptions in Java code. [HW1] ++ Be able to write correct Java code for simple methods, given an interface, and specifications in javadocs, JML annotations, and/or JUnit tests. [HW2] ++ Be able to declare fields to represent a specified ADT's data, and to write Java code for methods to implement that specification. * Inheritance and Polymorphism - Be able to explain the difference between inheritance and behavioral subtyping. - Be able to read Java code that defines recursive, tree-like ADTs. - Be able to answer questions about the fields and methods found in a subclass object given Java code for the superclass and subclass. - Be able to determine the effects of method calls when subtyping and polymorphism are used (in subclasses and implementations of interfaces), especially in for down calls to overridden methods. - Be able to read and write constructors and methods that use "super" to inherit behavior from the class's superclass. - Explain what an abstract method is, and when to use it in Java; explain what an abstract class is. - Be able to explain what statements or expressions violate Java's privacy rules for clients and subclasses when the superclass's uses "protected" visibility. - Be able to diagnose violations of Reil's heuristics for inheritance, as found in chapter 5 [HW1, expressions]. - Be able to refactor code for recursive types so that it no longer violates these design heuristics. This includes knowing when to use interfaces (implements in Java), instead of inheritance (extends in Java) for implementing a class.