Professional Documents
Culture Documents
Level Three
Duration 2 hours
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) Explain how assertions may be used to support contracts in Java. Your answer
should outline the advantages and disadvantages of using them and include an
example of an assertion.
[9 marks]
(b)
i) What are the advantages of substitutability of subtypes? Your answer
should explain the principle of substitutability of subtypes and include an
example (in English, not Java code).
[5 marks]
(ii) Study the code below. Will it compile? Explain your answer in detail. If
you don’t think the code will compile, identify any changes you could
make so that it will compile. Line numbers are included to assist you with
referring to specific code in your explanation.
[6 marks]
(iii)
1. class BIGCAT {}
2. class BIGBIRD {}
3. class TIGER extends BIGCAT {}
4. class EAGLE extends BIGBIRD {}
5. public class Substitute {
6. public static void main(String[] args) {
7. BIGCAT w;
8. BIGBIRD y;
9. TIGER x;
10. EAGLE z;
11. x = new TIGER();
12. z = new EAGLE();
13. z = y;
14. w = x;
15. }
16. }
(c)
(i) Explain why design patterns are used in the software development process
and highlight the benefits that can be achieved.
[10 marks]
(ii) The presentation tier of a large application has to handle many user
requests and ensure they are all processed. A typical solution to managing
the requests is to use the Front Controller Pattern. Give an outline of how
this patterns works and the problem is it trying to solve.
[10 marks]
___________________________________________________________________
COMP1307 Object Oriented Software Development
Page 2 of 4
FINAL
2. You have been asked to design a website for an on-line Chinese take-away
restaurant. Instead of forming a queue at the counter to order your food and
waiting for your order, the new website will allow customers to order and pay
directly from their smart phones (3G or wi-fi capable). The screen will allow
customers to choose food and drink, and then place an order and pay on-line with
a credit card. An order number will be issued to the customer for each order as
well as an approximate time for collection. The food will then be delivered to the
counter for pick up when they are ready.
(a) The system you have been asked to design is required to use a combination of
JSP and Servlet technologies as appropriate. Write a brief report stating why
you would choose to use each of these technologies and give examples related
to the above scenario explaining for what parts of the system you would
choose to use JSPs and for what parts you would choose to use Servlets. (You
are not required to write any Java code).
[16 marks]
(b) Outline the Struts framework and discuss whether you would choose to use it
in the Chinese take-away restaurant scenario given above.
[14 marks]
3.
(a) What is an exception? Explain why Java provides a mechanism for handling
exceptions and give an example of how this mechanism works.
[10 marks]
try {
for ( int i=0; i<9; i++ ) {
System.out.println(a[i]);
}
}
catch (Exception e) { }
[4 marks]
(c) The code given below shows one way of declaring and starting a new thread.
___________________________________________________________________
COMP1307 Object Oriented Software Development
Page 3 of 4
FINAL
(new MyThread()).start();
Defining threads by directly extending the Thread class is one option provided
by Java. Explain why it may not always be possible to use this option, and re-
write the code for the above class showing an alternative means of defining a
thread. You answer should include the code defined above which calls the
start method, with a brief explanation of how it works.
[6 marks]
(d) Describe the lifecycle of a thread and how the Java virtual machine
implements thread priorities.
[10 marks]
4.
(a) Give the properties of an abstract class and explain why a software engineer
might choose to abstract classes in software design.
[6 marks]
(b) In the context of the code shown below, explain the meaning and effect of the
key words “static”, “final” and “protected”. You will notice that neither class
has a modifier, e.g. “public” in the class declaration. What does this mean in
terms of how accessible these classes are by others?
(c) You are currently a consultant to a small company which wants you to set up a
database to manage their staff timesheets. Some staff work from home and
they would like the system to be available over the internet. Speed is not a
priority as there are only a few staff. They expect to use an Access database
which they all have readily available on their home machines. As a first step
you have been asked to write a critical review comparing and contrasting the
four types of JDBC driver and to clearly state which one you would
recommend they use and why.
[16 marks]
___________________________________________________________________
COMP1307 Object Oriented Software Development
Page 4 of 4