MSc/ICY Java Workshop

Welcome to the pages for the MSc/ICY Software Workshop 1 & 2 at the School of Computer Science. You should bookmark this page as you will need to refer to this site frequently throughout the course.

Course Material

New material will be updated as the course continues, week by week. You will be able to find these in the following sections.

WeekLecture HandoutExercise Tutorial HandoutReading
01 Pocket calculator type computations, simple strings, variables

platform dependence; programs have to be understandable to computers and humans; write programs by opening a terminal, editing a file, saving, compiling and running it; Math class; meaning of assignment. Lab Lecture on Friday with easy problems.

Exercises
Due:
10 Oct
solution
- [Deitel & Deitel] Chapters 1 and 2 on Intro to Computers, the Internet and the Web and Introduction to Java Applications.
02 Classes and objects, JavaDoc, Eclipse

In the Tuesday lecture we introduced the central concepts of classes and objects. Furthermore we looked at JavaDoc

The Friday lab lectures were devoted to the Eclipse IDE.

Exercises
Due:
24 Oct
solution
Tutorial Handout [Deitel & Deitel] Chapter 3 on Introduction to Classes and Objects
03 Types, control structures, JUnit tests

integer types, float types, boolean, char; conditionals if-then-else, case; loops such as while loops and for loops.

- Tutorial Handout [Deitel & Deitel] Chapters 4 and 5 on Control Statements: Part 1 and 2 (excluding parts on GUIs), Appendix D on Primitive Types
04 Arrays, ArrayLists, printf, scanner

arrays and ArrayLists are introduced and compared. Furthermore some syntactic sugar and the scanner to read in data. The BankAccount example is extended by a statement using an ArrayList.

Exercises
Due:
7 Nov
solution
Tutorial Handout [Deitel & Deitel] Chapter 7 on Arrays and ArrayLists (excluding parts on GUIs)
05 Exceptions, I/O, Patterns

Exception handling is introduced to avoid program crashes. Patterns to specify expected input and some I/O are presented.

- Tutorial Handout [Deitel & Deitel] Chapters 11, 16 and first half of 17 (17.1-17.4) on Exception Handling and Strings, Characters, Regular Expressions and File I/O
06 Classes revisited - Inheritance

In the Tuesday lecture we have a general revision lecture by discussing in detail the test from the previous Friday and its problems and pitfalls.

On Friday, we introduce Inheritance and see two simple examples: BankAccount with Overdraft and a Library system.

Exercises
Due:
21 Nov
solution
Tutorial Handout [Deitel & Deitel] Chapters 8 and 9 on Classes and Objects: A Deeper Look and Object-Oriented Programming: Inheritance
07 Packages, Inheritance On Tuesday we were looking at packages and the different access modifiers. Furthermore we looked at the Employee class as another example for inheritance. We also looked at answer to exercise sheet 2. - Tutorial Handout [Deitel & Deitel] Chapters 6 and 10 on Methods: A Deeper Look and Object-Oriented Programming: Polymorphism
08 Inheritance, Interfaces Interfaces can be considered as very abstract classes which specify contracts about the methods that are promised in them. The methods do not have any implementations in the interface itself, but only in classes that implement them. We will look at an example that goes beyond the Employee class. Exercises
Due:
5 Dec
solution
Tutorial Handout
src-wk8.zip
[Deitel & Deitel] Chapter 10.7 on Interfaces
09 Recursion
On Tuesday, the idea of recusion is presented as well as two examples are given.
- Tutorial Handout [Deitel & Deitel] Chapter 18 on Recusion
10 Recursion - Binary Trees
The Tuesday lecture was cancelled due to strike action. On Friday we discussed Binary Trees and had the second in-class test.
Exercises
Due:
12 Dec
solution
Tutorial Handout [Deitel & Deitel] Chapter 18 on Recusion
11 Recursion - Binary Trees - treeSort
In the Tuesday lecture we continued with binary trees and introduced treeSort, a method to sort a list by first tranforming it into a binary search tree and then back in a list by taking the elements in "in-order".
- - [Deitel & Deitel] Chapter 18 on Recusion

Last year's exam paper can be found locally as java13.pdf.

Useful Resources

If you get stuck, the first port of call is research. Here are some links which will help you get started, and access to resources to help build confidence around this subject.

  • Coding Bat Java Challenges A series of Java challenges, you can try in the browser, and then see your performance tested straight away. Useful for getting in a few extra hours practice, on some puzzlers.
  • Java Library Documentation: On this course, we use primarily use Java 1.6 SE. The API (Application Programming Interface) reference contains information about the built in Java SDK (Software Development Kit) library code. You will need this when you start to use library code. You will also learn how to create an API, like the java one, for your own code.
  • Java Style: Java is a High-Level, Object Oriented Language, however you're code still needs to be easy to read. As a result there are many conventions, and guide lines, on how to write readable code that is easy to understand.
  • Documenting Java Code: Any code you write should be documented. Java advocates a particular structure of documentation, which the Javadoc tool can automatically turn into API reference documents (such as those mentioned above). This overview on how to structure code documentation for Javadoc provides the essentials. The Javadoc documentation provides full details, and finally there are guidelines on how to describe, inside such documentation comments, the actual behaviour of your program.
  • Java Trails: The Java Trails are a set of tutorials maintained by Oracle, the current Java developers. They are designed to get you programming Java from scratch, including lots of worked examples. They have been updated to cover Java 7, the latest version of Java, which is slightly newer that the version we run in labs, so be warned that some features they describe are not available for use in the School (e.g. switch statements on Strings).
  • JUnit: We use JUnit 4 for testing. Our JUnit cheatsheet explains the very basics. You may find further information on the JUnit homepage. Initially we will be using JUnit from the command line, but note that integrated development environments such as Eclipse also have built-in JUnit support.
  • Downloading Java Software Development Kit: If you wish you can download the Java Software Development Kit for use on your own computer for free from the SUN Java website JDK Download, choose "Java SE Development Kit (JDK)". However, we can not answer question about getting Java working on your own computer and strongly recommend you use the lab computers to complete your exercises. Your code may not work if you create it in a different environment to where you expect to run it, some of your exercises may be demonstrated in the lab and must work on lab machines.
  • Linux: The lab machines use the open source Linux Operating System, as opposed to more popular operating systems such as Microsoft Windows or Apple OSX. If you are considering using Linux at home the distribution of Linux used in the labs is CentOS 5 but you might well find Ubuntu to be a more user friendly Linux Distribution. There is usually a Linux install party every year in the student common room, where other students will help you with all aspects of installing Linux on your own computer (we will let you know about this on the blog).
    There is a short course on Unix available here.