Computer Laboratory > Teaching > Course material 2008–09 > Programming in Java


Programming in Java

Principal lecturers: Dr Alastair Beresford, Dr Andrew Rice
Taken by: Part IA CST, Part IA NST, Part I PPS
Past exam questions

Meet the lecturers

Andrew RiceAlastair Beresford


Competition entries for Tick 4*

Click here to see all the submissions

Competition entries for Tick 6*

Click here for a description of how each submission works

What do I need to do for this course?

  • Attend the practical class at the appropriate time each week
  • On arrival, collect the workbook for the week (electronic copies below).
  • Sit at the correct workstation as shown on the seating plan
  • Work through the material in the workbook
  • If you have time, attempt the additional starred exercise
  • If you have time, take a look at the project suggestions

Remember to submit work by Wednesday at 5pm on the week following the practical class; submission instructions are contained in the workbook for the week.

Local documentation


The workbook for each practical class will appear here just prior to the start of the practical session.


Please complete the following questionnaires after you have completed the associated workbook and tick. You should print out questionnaire, fill in the appropriate fields and hand it in to your ticker at the next ticking session.

Project suggestions

Useful external links

Workbook errata

The printed workbooks contain (at the very least!) the following errors. Errors are indexed by workbook (W), page (P) and line (L), which may be negative, indicating that the reader should count upwards from the bottom of the page. These errors have been corrected in the on-line versions of the workbooks shown above. If you find any further errors, please email ticks1a-admin[at]

113-4This course relies heavily on the material taught in Software Design and Programming Methods and these courses are lectured concurrently with this course.This course relies heavily on the material taught concurrently in Software Design and Programming Methods.fhk1
1524-26The option for printing "AM" or "PM" does not work on PWF machinesAn answer which does not display "AM" or "PM" on the PWF workstations is permissible.gh323
188"String args[]"A better form is "String[] args"acr31
1825"String args[]"A better form is "String[] args"acr31
1827"String args[]"A better form is "String[] args"acr31
11018"String args[]"A better form is "String[] args"acr31
2420Java does not round upJava rounds towards zerojrb95
27-8the 8-bit binary number 1001100the 8-bit binary number 10001100sgb35
21042 != (!(12 == 3))true != (!(12 == 3))ha293
21112The valid range for the position variable is unclear.Add the comment "position counts from zero (representing the least significant bit) up to 63 (representing the most significant bit)"acr31
298boolean t4 = t1 | t2 & t3; //falseboolean t4 = t1 | t2 & t3; //trueiv228
211-6new Long(args[0]).longValue()Long.decode(args[0])ljg39
3210v = PackedLong.set(v,i)v = PackedLong.set(v,i,val)jkm47
375-6The method should return the updated version of method at the end of the method body.The method should return the updated version of world at the end of the method body.crh55
373,7,12getNeighbourscountNeighboursha293, jrb95
3*1-12myArray[i] = 1000;myArray[i] = 1000L;jrb95
3*25Missing a class file in the list of contents of the jar fileuk/ac/cam/crsid/tick3star/PackedLong.classjrb95
426intArray[2] = intArray[2] + 7;intArray[2] = intArray[0] + 7;prc33
42-15Insufficient examples for the method storeInclude the following examples in the comments: store(0) should store nothing; and store(6) should store 1,1,2,3,5,8 in first six elements of fibacr31
44-7Figure 1 labels three cells as j[2][1]Each cell is unique in the diagram; the second and third cells labelled j[2][1] should be labelled j[2][2] and j[2][3] respectively.djm208
44-7Figure 1 labels two cells as j[1][1]Each cell is unique in the diagram; the second cell labelled j[1][1] should be labelled j[1][2].arb33
45-7Notice that none of the methods now return an updated version of worldNotice that setCell does not return an updated version of world.mb566
47-6this storage space is called a field if appears inside the bodythis storage space is called a field if it appears inside the bodydr336
4911"The University of Cambridge is "+800+"years old""The University of Cambridge is "+800+" years old"jrb95
41017(0,1), (1,2), (2,0), (2,1)(1,0), (2,1), (0,2), (1,2)oc243
41019(1,2), (2,3), (3,1), (3,2)(2,1), (3,2), (1,3), (2,3)oc243
41219private int startXprivate int startX;jrb95
413-7Missing PackedLong in the jar fileNeed uk/ac/cam/crsid/tick4/ and uk/ac/cam/crsid/tick4/PackedLong.classjrb95
51-5a method call from line 96 of PatternLife.javathe constructor on line 96 of PatternLife.javajrb95
53-2until an enclosing try-catch block is founduntil an enclosing try-catch block is found which catches an exception of the correct typejrb95
5314should return "one one one"should return "one one one". Adjacent copies of the repeated string should be separated by a single space.drt24
57-13two letter string "\r\n"two character string "\r\n"jrb95
510-2without unpacking the jar filewithout explicitly specifying a class to executejrb95
5*1-17the growth rate is 2.0the growth rate is 1.0ls475
681String first = "a";String first = new String("a");jrb95
682String second = "a";String second = new String("a");jrb95
61021public void World nextGeneration(int log2StepSize)public World nextGeneration(int log2StepSize)oc243
748Missing import statementimport javax.swing.JScrollPanelr331
75-5only onlyonlyia264
7627superclasssuper classarb33
712-15char userResponse = 0;int userResponse = 0;oc243
7141Missing hint in optional workExtra hintacr31
7146Tick 6Tick 7rhm31
8212class which is handlesclass which handleslr331
8317the two classes to workthe two classes workta299
8618Numbering of exercises repeatsThis block of exercises should be numbered from 3ia264
8618the second version of HelloActionWorldHelloActionWorld2lr331
8622by deleted the fieldby deleting the fieldvv236
87-10Extra hintHint: since playTimer is not a static field, you will need to access the field from the instance of GuiLife you have already created called guivv236
88-8Extra hintHint: You'll need to import ChangeListener and ChangeEventvv236
813-11Its very slowIt's very slowjn283