Object Oriented Programming (Java)
Inheritance, polymorphism, exceptions, files, recursion and generics.
Textbook: Paul Deitel, Harvey Deitel, Java: How to Program, Pearson, ISBN-10: 0132575663
- Week 1Classes and Objects
- Classes and objects: reviewFields, constructors, this, encapsulation, static vs instance, toString and equals. The rest of the semester builds on this foundation.
- Week 2Inheritance
- Inheritance: extends, super and the constructor chainWhat a subclass gets from its superclass, in what order constructors run, and the difference between overriding and overloading. A favorite of output questions.
- Week 3Polymorphism
- Polymorphism: dynamic binding, upcasting, downcastingWhich method runs when a superclass-typed variable holds a subclass object, what the compiler accepts, and when a cast blows up.
- Week 4Polymorphism II: Abstract Classes and Interfaces
- Abstract classes and interfacesabstract methods, interfaces, default methods, multiple interfaces and sorting with Comparable. The main source of compile-error questions.
- Week 5GUI Components
- GUI components: JFrame, JLabel, JTextField, JButton and layoutsBuilding a window with Swing: components, the content pane, and FlowLayout, BorderLayout, GridLayout. Code-reading and 'which layout' questions in the exam.
- Week 6GUI and Event-driven Programming
- Event-driven programming: listeners, anonymous classes, lambdasWhat happens when a button is clicked: the event source, the listener interface, registration, getSource, and writing the handler as an inner class, an anonymous class or a lambda.
- Week 7Case Study: Object Oriented Design with the UML
- Object-oriented design with UMLReading and writing class diagrams: visibility markers, relationship arrows, multiplicity, the aggregation vs composition difference, and going from a requirements text to classes.
- Week 8Strings, Characters and Regular Expressions
- String, StringBuilder, Character and regular expressionsString methods and immutability, mutable text with StringBuilder, the Character class, and validation, split and replaceAll with regex. A topic full of short output questions.
- Week 9Exception Handling
- Exception handling: try, catch, finally, throw, throwsWhere control goes when an error happens, when finally runs, the checked vs unchecked difference, and writing your own exception class. The favorite of output-tracing questions.
- Week 10Midterm Review
- Midterm review: weeks 1-9 mixedA one-page summary of every topic on the midterm, from classes to exceptions, and 12 exam-style questions that mix the topics together.
- Week 11Files and Streams, Object Serialization
- Files, streams and object serializationFile operations with Files and Path, reading with Scanner, writing with PrintWriter and Formatter, try-with-resources, and saving objects with ObjectOutputStream.
- Week 12Recursion
- RecursionMethods that call themselves: base case, recursive step, tracing the call stack, and factorial, Fibonacci, powers, palindromes, binary search. The second big source of output-tracing questions.
- Week 13Searching and Sorting (Selection, Insertion, Merge Sort)
- Searching and sorting: linear, binary, selection, insertion, merge sortTwo search and three sorting algorithms, the state of the array after each pass, and a Big-O comparison. The exam asks 'what does the array look like after pass 2'.
- Week 14Generic Classes and Methods
- Generics: generic methods, generic classes, wildcardsMethods and classes that take a type as a parameter: <T>, bounded types (T extends Comparable<T>), ArrayList<T> and an introduction to wildcards. The last big source of compile-error questions.