Professional Documents
Culture Documents
Level Three
Answer TWO questions from the remaining THREE questions, questions 2 to 4 which are
worth 30 marks each. If you answer all THREE questions from questions 2 to 4, marks will
ONLY be awarded for your TWO best answers.
Section A – (Compulsory)
1. (a)
(i) Explain how packages provide programmers with a way to manage
and organise class files within a large scale system. Your answer should
include an explanation of what access classes within a package have to each
other’s data and methods.
[8 marks]
(ii) The Accounts class given below meets two of the requirements for
the canonical form of classes – it implements the Cloneable and Serializable
interfaces. Describe the remaining requirements for canonical form and
implement them. You do not need to write the details of code for any new
methods, just write the method signatures and explain what code would be
required.
(b) You are introducing good practice for object-oriented system development
to a company which has no previous experience of design patterns. As a
senior software consultant, you gave a seminar on design patterns. The
following questions were asked by the audience at the end.
[6 marks]
2. The code below is part of a system which simulates robots. Robot objects can be
created and information about method calls (for example the number of times the
move() method is called) is computed.
2. public int x, y;
3. private int instanceMoveCount;
4. static private int classMoveCount;
(a) Explain the differences between class (static) methods and instance
methods.
[6 marks]
(b) Predict what the program above does when loaded, and what the output will
be. You may use the line numbers in your explanation, but you do NOT
have to explain every line – just explain the main functionality.
[10 marks]
(c) Another way of keeping track of the total number of times the move()
method is executed would be to use some object (say an instance of a class
called Counter) with an instance variable storing the number. The Singleton
design pattern could be used in such a case.
[6 marks]
(ii) Explain the purpose of the Singleton pattern and say if it would be
appropriate to use it in the given code example and explain why.
[8 marks]
3. (a) Discuss the DAO pattern and explain its use of the Transfer Object Pattern in
JEE applications.
[15 marks]
(b) Compare and contrast the use of servlets and java server pages for building
dynamic Web applications. In your answer, stress the relative advantages
and disadvantages of these two technologies.
[15 marks]
Describe how you would rewrite this program in such a way that each of
these exceptions could be handled.
class Exceptions {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = a / b;
System.out.println("The answer is " + c);
}
}
[9 marks]
[9 marks]
(c) (i) Give an account of the different testing phases that are commonly
used in the development of software systems.
[6 marks]
(ii) Identify the testing phases of a Java software system where the
framework JUnit may be used, and describe briefly the way this
framework operates.
[6 marks]