Documente Academic
Documente Profesional
Documente Cultură
Level Three
_________________________________________________________________
Object Oriented Software Development
COMP1307
APPROVED
1. (a) You have been asked to give a seminar to a local small software
development company on why contracts of methods are considered
good software design. You will need to discuss the reasons for using
contracts of methods and should provide an example of a contract
with an explanation of it. Prepare key notes for your talk.
[12 marks]
(b) Clearly state which of the methods in the class below are required to
meet the canonical form of classes and why? Are there any methods
missing, if so clearly state which methods and why they are needed?
[13 marks]
__________________________________________________________________ 2
Object Oriented Software Development
COMP1307
APPROVED
2. (a) Java provides two mechanisms for writing threads. State these
mechanisms and compare their use.
[5 marks]
(b) Discuss the “bounded queue” problem and briefly describe a solution
to it outlining the complexities of solving this problem.
[12 marks]
(c) Java exceptions can be divided into three main categories, what are
these categories? Explain the advantages of the exception handling
mechanism in Java and give an example of how exceptions may be
handled.
[8 marks]
__________________________________________________________________ 3
Object Oriented Software Development
COMP1307
APPROVED
3. You have been called to a small local company as an advisor to their small
IT team (3 people) who have developed an in-house stock control system
using mainly JSPs and servlets. They are finding it increasingly harder to
maintain over time as the business logic is all muddled up with presentation
code etc. They are seeking your advice about how to write more
maintainable code.
(a) Explain the basics of how tag libraries work and the benefits that
they might obtain as a result of using them.
[10 marks]
(b) Write a brief report for the company outlining the advantage of the
Struts framework and explain why this structure might help them
produce more maintainable code in future.
[15 marks]
__________________________________________________________________ 4
Object Oriented Software Development
COMP1307
APPROVED
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.
[4 marks]
__________________________________________________________________ 5
Object Oriented Software Development
COMP1307
APPROVED
Question 4 continued:
(b) Predict what the program above does when loaded, and what is the
output. 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 the class called Counter) with an instance variable
storing the number. The Singleton design pattern could be used in
such a case.
Explain the purpose of the Singleton pattern and say why it would
be appropriate to use it in the example given.
[5 marks]
[6 marks]
__________________________________________________________________ 6
Object Oriented Software Development
COMP1307
APPROVED
• Interfaces
• Implementations
• Algorithms
[6 marks]
1. import java.util.*;
2. import java.io.*;
19. System.out.println(y);
20. System.out.println(x.size());
21. }
22. }
__________________________________________________________________ 7
Object Oriented Software Development
COMP1307
APPROVED
Question 5 continued:
[10 marks]
(d) The program in (c) uses a HashSet object. What differences would
be noticed if a TreeSet object were used instead?
[3 marks]
__________________________________________________________________ 8
Object Oriented Software Development
COMP1307
APPROVED
The system enables the user to select a shape (for example a square
or a circle) from a menu. The shape is then drawn on the “drawing
screen”, and the user can then, by selecting from menus, change the
position, size and colour of the drawn shape. A drawn shape can
also be deleted. The screen can display many shapes at once, and
store the whole screen to a file, so that later the screen can be
reloaded.
4. }
Question 6 continued:
[4 marks]
(c) State the code for a class called TestShape with a main() method
creates an instance of Square and prints (to the standard output) its
area.
[3 marks]
(d) Draw a UML diagram with the classes Shape, Square and TestShape
included.
[4 marks]
[6 marks]
(f) Storing the drawing screen could be done by writing data from the
object list to a file. Explain how this can be done.
[4 marks]
__________________________________________________________________ 10
Object Oriented Software Development
COMP1307