Programming Methods

Supervision 1

Please answer the following questions from the Programming Methods examples sheet: 2, 3, 4, 5, 6, 8, 12-20

Supervision 2

Please answer the following questions from the above exercise sheet:

21, 22, 23, 26, 27, 28, 29, 30, 32, 34, 35

Software Design

Supervision 1

Please answer the following questions:

  1. Define the terms 'class' and 'instance'. In Java, what is required for an object at runtime to be of some class X?
  2. Suppose you are implementing an interpreter for Java. What do you need to store to represent a class instance? What about a class?
  3. How do Java interfaces support the idea of abstraction? Give a real-world example of how you might use that support.
  4. Give a few examples of the Java Collections library making use of abstraction.
  5. How can excessive abstraction reduce the efficiency of programs?
  6. Suppose you were designing a web server. At the moment you're developing for Linux, but looking to the future you want to be able to produce a version that runs on Windows too. What would be a sensible way to modularise the program in view of this goal? How might you go about said modularisation?
  7. Give an example (in Java) of two classes, one of which is a subclass of the other. Let the first have a method which the other overrides: in what circumstances will one or the other version of the method get run?
  8. Suppose A subclasses B. Is it always safe to use an A where a B is required? What about vice versa? Why?
  9. Suppose you have two references to an X, call them i and j. When is i == j? When is i.equals(j)? Does i.equals(j) imply j.equals(i) or vice versa?

Supervision 2

2007 Paper 2 Question 7

2006 Paper 2 Question 7

Supervision 3

2008 Paper 2 Question 7

2000 Paper 7 Question 13