Você está na página 1de 12

DESIGNING AND DEVELOPING

OBJECT-ORIENTED
COMPUTER SYSTEMS

SAMPLE

MARKING SCHEME


This Marking Scheme has been prepared as a guide only to markers. This is not a set of model
answers, nor is the Marking Scheme exclusive, for there will frequently be alternative responses
which will provide a valid answer. Unless a question specifies that an answer be produced in a
particular form, then an answer that is correct, factually or in practical terms, must be given the
available marks.

If there is doubt as to the correctness of an answer the relevant NCC Education materials and
associated module textbook should be the first authority.




Throughout the question, please credit any valid alternative point.


Notice to Markers

Where markers award half marks in any part of a question they should ensure that the total
mark recorded for a task is rounded up to a whole mark.




QUESTIONS CONTINUE ON NEXT PAGE
Page 2 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012

ANSWER ALL QUESTIONS


QUESTION 1

Marks
a) State what is meant by a Context Sensitive Editor. 2
A word processing type program editor that has the facility to check the syntax of a particular
programming language. (2 marks)


b) Distinguish between a class and an object. 2
A class is a plan/template/definition from which an object can be created.(2 marks)

c) Explain why modern programming languages need to provide the means to create Graphical
User Interfaces.
3

Many modern applications are event driven. (1 mark)
A significant number of computer users expect to interact with a computer via a GUI.
(1 mark)
Without specific programming facilities to create GUIs implementation is very time
consuming. (1 mark)

d) Explain what is meant by an Event. 3

A happening external to a system that affects the behaviour of the system. (1 mark)
There are different types of event depending on the stimulus that generated the event.
(1 mark)
The method that responds to an event is specific to the functionality of the application
(1mark)

Total 10 Marks

QUESTIONS CONTINUE ON NEXT PAGE
Page 3 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012

Marks
QUESTION 2

a) J ava is a blocked structured programming language.
Explain what is meant by blocked structured in this context.
1

The programmer is constrained to organize program code in blocks delimited by { }.
Each block has a specific purpose.
(1 mark for an explanation similar to the above)

b) J ava is a strongly typed language.
Explain what is meant by strongly typed in this context. Illustrate your answer with examples of
TWO (2) distinct types.
2
The programmer must declare all variables and fields as a specific type. (1 mark)

For example:
int PartNumber;
String Description;
(1 mark for showing two distinct types)

c) Describe what happens when an object is instanced. 3

The program code of the instancing class is executed. (1 mark)
The constructor is only executed when new instance of an object is created. (1 mark)
The name of the object is associated with the field definitions and methods detailed within
the program code of the class. (1 mark)

d) Write down the exact output that the following program code would produce:
String S = "QWERT";
String sub = "";
sub = S.substring(1,4);
System.out.println(sub);
sub = S.substring(2,2);
System.out.println(sub);
sub = S.substring(2,4);
System.out.println(sub);
System.out.println(S.length());
4


WER (1 mark)
(1 mark)
ER (1 mark)
5 (1 mark)

Total 10 Marks


QUESTIONS CONTINUE ON NEXT PAGE
Page 4 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012



QUESTION 3

Marks
a) Explain why Encapsulation is an important concept in the context of Object Orientation. 2

From the point of view of security and robustness it is important for the program code in a
class that instantiates an object not to be necessarily visible to the programmer and never
visible to the user. (2 marks)

b) Explain why the statement:
class MyGUI extends JFrame
is an example of Inheritance.
2

The new class MyGUI will inherit the field definitions and methods of the existing JFrame
class. (1 mark)
Thus these field definitions and methods can be considered as though they were defined in
the MyGUI class. (1 mark)


c) State TWO (2) ways in which a constructor differs from a method. 2

It cannot have a return type.(1 mark)
It is only executed once and that is when the instanced object is first created. (1 mark)

d) Describe what is meant by the visibility of a field and a method. 4

Fields and methods are defined within a class body. The programmer needs to determine
what other classes can have access to these fields and methods. (2 marks)
This is achieved by defining each field and method with a visibility declaration such as
private, protected or public. (2 marks)

Total 10 Marks


QUESTIONS CONTINUE ON NEXT PAGE
Page 5 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


QUESTION 4

Marks
a) Show example program code of:
An integer value being cast to a double type.
A double value being cast as a String type.
4
double d;
int i = 9876;
d = (double) i;
(2 marks for the above 1 mark off for each mistake)

double d = 7845.98;
String s = "";
s = Double.toString(d);
(2 marks for the above 1 mark off for each mistake)

b) Consider the following program code:
package pkQ4b;
import java.awt.*;
import javax.swing.*;

public class Q4b
{
public static void main(String[] args)
{
Q4b MyQ4b = new Q4b();
MyQ4b.go();
}
public void go()
{
Q4GUI MyGUI = new Q4GUI();
}
class Q4GUI extends JFrame
{
public Q4GUI()
{
this.setSize(400,400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setBackground(Color.RED);
this.setVisible(true);
this.add(new PaintSurface(), BorderLayout.CENTER);
}
}
private class PaintSurface extends JComponent
{
public PaintSurface()
{}
public void paint(Graphics g)
{
Graphics2D Myg = (Graphics2D) g;
Myg.drawLine(0, 0, 300, 300);
}
}
}

QUESTIONS CONTINUE ON NEXT PAGE
Page 6 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


Marks
b) i) Describe the output that this program code would produce. 2
A rectangular frame filled with a red colour and a black diagonal line drawn from the top
left hand corner. (2 marks)

ii) Explain the purpose of the statement:
import javax.swing.*;
2
Makes all the functionality (e.g. classes and thus methods) of the swing GUI technology
(package) available for use in the program. (2 marks)

iii) Describe the implication of void. 2
Prevents a method having a return type. (2 marks)

Total 10 Marks

QUESTIONS CONTINUE ON NEXT PAGE
Page 7 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012

Marks
QUESTION 5

a) Describe the nature and the purpose of an Event Listener. 2

It is derived from a class encapsulated in the awt package.
It is an interface object that is often instanced by a GUI class that has inherited from a
JFrame
A Listener object is notified when an event has occurred.
(1 mark for each bullet point up to a maximum of 2 marks)


b) Distinguish between the swing component classes J Button and J TextArea. 2

A button object is generally clicked to initiate the execution of a specific block of program
code. (1 mark)
A text-area object is generally for inputting and/or displaying multiple lines of text from a
single string. (1 mark)

c) State TWO (2) reasons for using an instanced J ComboBox swing component. 2

To display a list of text items. (1 mark)
To have the facility to select an item from a displayed list. (1 mark)

d) A combo box object does not support a sort method.
Describe how the facilities of the J ava language can be used to sort a list of names displayed in a
combo box into alphabetic order without programming a sort method.
4
A simple array structure has a sort method hence a process could be:
Copy all the names in the combo box into a simple string array. (1 mark)
Sort the contents of the array using its sort method. (1 mark)
Remove all the items from the combo box. (1 mark)
Repopulate the combo box with the elements of the array. (1 mark)


Total 10 Marks
J


QUESTIONS CONTINUE ON NEXT PAGE
Page 8 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


Marks
QUESTION 6

a) The Unified Software Development Process uses an iterative approach.
Explain what iterative means in this context.
2
Each iteration involves analysing what is required, creating a design, programming the design
and testing the program code. (2 marks)


b) In the analysis stage of the development process it is necessary to identify the Actors.
List TWO (2) questions that should be posed to identify the Actors.
2

Who provides information to the application?
Who would use the application?
Who would retrieve information from the application?
What other systems would the application use?
( 1 mark each bullet point up to a maximum of 2 marks))

c) A class diagram shows the classes, their attributes (fields and their operations (methods).
Describe how attributes and operations are determined.
4

Attributes are the individual items of data required for each class determined by
examining the users requirements/use cases and considering the data that needs to be
input and output. (2 marks)
Operations are determined by examining the users requirements/use cases and
considering the tasks that users will need to perform. (2 marks)

d) A class diagram also indicates the relationships between classes.
Describe TWO (2) such relationships.
2

An inner class that is defined inside another class.
A class that creates an instance of another class.
A class that inherits attribute definitions and methods from another class.
(1 mark each bullet point up to a maximum of 2 marks)

Total 10 Marks

QUESTIONS CONTINUE ON NEXT PAGE
Page 9 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


Marks
QUESTION 7

a) Describe what is meant by defensive programming. 3
The programmer identifies which blocks of code could fail in unusual circumstances (1
mark); e.g. in any block that involves numeric division or array index arithmetic (1
mark). The programmer inserts extra code to trap such situations OR insert a try catch
structure OR both (1 mark).


b) Describe an example situation where the value of a data item could be valid but not correct. 1
12/10/2005 is a valid date but the user should have entered 21/10/2005.

c) Describe how the sensible use of certain swing components to design a GUI could eliminate the
need to be concerned with data validation.
3
Any swing component that displays a list of predefined valid options (2 marks)
with no opportunity for the user to select any other option. (1 mark)

d) Explain why some programmers may choose to enclose the program code of every method with
a try - catch structure that would identify the method should an exception occur.
3
This is a particularly useful approach during the development of a program
as the execution is not halted at the first exception (1 mark) thus increasing the possibility of
more than one location of erroneous code being detected per run (1 mark). Also useful in an
operational program to prevent intelligiblesystem messages being displayed. (1 mark)


Total 10 Marks







QUESTIONS CONTINUE ON NEXT PAGE
Page 10 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


Marks
QUESTION 8

a) Generally J ava parameters are passed by value.
Describe the meaning of this statement and state the implication for the programmer.
3

The storage location associated with a parameter is not communicated when the
parameter is passed; only the value is passed. (2 marks)
Thus if the block of code that receives the value changes that value the new value is not
passed back to the calling block. (1 mark)


b) State in what structure a class library is stored. 1
Package (1 mark)

c) Explain how the Accessors Get and Set improve the encapsulation of a class. 2

They allow fields to be declared as private. (1 mark)
The value of any private field can only be accessed via its Accessor. (1 mark)


d) Although the use of Accessors does not achieve total encapsulation there are three important
spin-offs from them.
State these three spin-offs.
4
A readonly method can be achieved by providing a Get but no Set. (2 marks)
The Set can perform encapsulated data validation. (1 mark)
The Get can perform encapsulated calculations where only the result is exposed. (1 mark)


Total 10 Marks



QUESTIONS CONTINUE ON NEXT PAGE
Page 11 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


Marks
QUESTION 9

a) Explain how a simple array data structure enables direct access to its elements. 2

Each element of an array is addressed by its index. (1 mark)
Hence only the value of the index is required to access an element of a simple array.
(1 mark)


b) Describe a J ava data structure that can represent a real world table of data. 2

A real world table of data can be represented by a two dimensional array. (1 mark)
Each element of the array is identified by two indices; column number, row number.
(1 mark)

c) State TWO (2) reasons, from a programmers point of view, why an ArrayList structure is
preferable to an Array structure.

State, from a system point of view, why an ArrayList structure offers little advantage.
3

To insert and delete elements in an Array, the programmer has to design code that will
perform a great deal of shifting of elements whereas an ArrayList has embedded methods
to perform such actions.
The size of an Array has to be defined and it will not expand or contract as required
whereas an ArrayList resizes itself automatically.
The functionality of an ArrayList is achieved by the internal manipulation of Arrays
which implies that there is no overall gain in execution efficiency.
(1.5 marks each bullet point up to a maximum of 3 marks)

d) Explain the basic mechanism of a LinkedList data structure.
State TWO (2) advantages of this data structure.

3

Each element of a linked list has a forward pointer that points to the next element in the
list and a back pointer that points to the previous element in the list.
As the list is managed entirely by the values of the pointers then no movement of contents
of elements is involved hence the management processes are much faster than the
equivalent processes for an Array or ArrayList.
There is no concept of defining the size of a LinkedList. A LinkedList could go on
expanding until the available memory of the computer runs out.
(1.5 marks each bullet point up to a maximum of 3 marks)



Total 10 Marks

END OF EXAM
Page 12 of 12

Designing and Developing Object-Oriented Computer Systems Sample Formatted/HW NCC Education Ltd 2012


Marks
QUESTION 10

a) A J ava program attempts to read a text file that consists of five lines of text.
State what happens if the program attempts to read a sixth line of text.
1
A null string will be read by the program. (1 mark)


b) Writing and reading data to and from a text file is restricted to reading and writing single strings.
Explain how such a system can read and write records that consist of several data items.
3
This can be done if each data item could be cast to a string. (1 mark)

In which case:
Writing
All cast data items are concatenated into a single string.
This single string is written to the text file.
(1 mark for the above)

Reading
The single string is read from the text file.
This string are split back and cast into the original data items.
(1 mark for the above)

c) Describe the special facilities that J ava provides to assist with the processes as detailed in your
answer to (b) above.
4
If each data item in the concatenated string (WholeRecord) is delimited with a tab character
then the splitting back process could be assisted by the statement:
String[] MyData = WholeRecord.split(\t);
(2 marks for the above)

Which has the outcome of inserting each string version of the data items into elements of the
array MyData.
Then each data item can be cast back to its original type by such a statement as:
int NumberInStock = Integer.parseInt(MyData[2]);
(2 marks for the above)

d) Describe how an appropriate data structure could be used to update the records in a text file. 2
Read the whole file record by record to become elements in a LinkedList. (1 mark)

Edit elements of the LinkedList as required to update the records.
Recreate the file from the LinkedList.
(1 mark for the above)


Total 10 Marks

Você também pode gostar