Department of Computer Science and Technology

Course pages 2018–19

Object-Oriented Programming

Principal lecturer: Dr Andrew Rice
Taken by: Part IA CST 50%, Part IA CST 75%, Part IA NST
Past exam questions

No. of lectures and practicals: 12 + 5
Suggested hours of supervisions: 3


The goal of this course is to provide students with an understanding of Object-Oriented Programming. Concepts are demonstrated in multiple languages, but the primary language is Java.

Lecture syllabus

  • Types, Objects and Classes Moving from functional to imperative. Functions, methods. Control flow. values, variables and types. Primitive Types. Classes as custom types. Objects vs Classes. Class definition, constructirs. Statioc data and methods.

  • Designing Classes Identifying classes. UML class diagrams. Modularity. Encapsulation/data hiding. Immutability. Access modifiers. Parameterised types (Generics).

  • Pointers, References and Memory Pointers and references. Reference types in Java. The call stack. The heap. Iteration and recursion. Pass-by-value and pass-by-reference.

  • Inheritance Inheritance. Casting. Shadowing. Overloading. Overriding. Abstract Methods and Classes.

  • Polymorphism and Multiple Inheritance Polymorphism in ML and Java. Multiple inheritance. Interfaces in Java.

  • Lifecycle of an Object Constructors and chaining. Destructors. Finalizers. Garbage Collection: reference counting, tracing.

  • Java Collections and Object Comparison Java Collection interface. Key classes. Collections class. Iteration options and the use of Iterator. Comparing primitives and objects. Operator overloading.

  • Error Handling Types of errors. Limitations of return values. Deferred error handling. Exceptions. Custom exceptions. Checked vs unchecked. Inappropriate use of exceptions. Assertions.

  • Copying Objects. Shallow and deep copies. Copy constructors. Cloning in Java. Cloneable as a marker interface in Java.

  • DesignLanguage evolution Need for languages to evolve. Generics in Java. Type erasure. Introduction to Java 8: Lambda functions, functions as values, method references, streams.

  • Design Patterns Introduction to design patterns. Open-closed principle. Examples of Singleton, Decorator, State, Composite, Strategy, Observer. [2 lectures]


At the end of the course students should

  • be familiar with the main features and limitations of the Java language;

  • be able to write a Java program to solve a well specified problem;

  • understand the principles of OOP;

  • be able to demonstrate good object-oriented programming skills in Java;

  • be able to describe, recognise, apply and implement selected design patterns in Java;

  • be familiar with common errors in Java and its associated libraries;

  • understand a Java program written by someone else;

  • be able to debug and test Java programs;

  • be familiar with major parts of Java 8 SE libraries;

  • understand how to read Javadoc library documentation and reuse library code.

Recommended reading

No single text book covers all of the topics in this course. For those new to OOP, the best introductions are usually found in the introductory programming texts for OOP languages (such as Java, python or C++). Look for those that are for people new to programming rather than those that are designed for programmers transitioning between languages (the Deitel book is highlighted for this reason). The web is also a very useful resource -- look for Java tutorials.

* Deitel, H.M. & Deitel, P.J. (2009). Java: How to Program. Prentice Hall (8th ed.).
Flanagan, D. (2005). Java in a nutshell : a desktop quick reference. O’Reilly (5th ed.).
Flanagan, D. (2004). Java examples in a nutshell : a tutorial companion to Java in a nutshell. O’Reilly (3rd ed.).
Gamma, E., Helm, R., Johnson, R. & Vlissides, A. (1995). Design patterns: elements of reusable object-oriented software. Addison-Wesley.
Bloch, J. & Gafter, N. (2005). Java puzzlers. Addison-Wesley.