PRG620S - PROGRAMMING 2 - 2ND OPP - JAN 2020


PRG620S - PROGRAMMING 2 - 2ND OPP - JAN 2020



1 Page 1

▲back to top


NAMIBIA UNIVERSITY
OF SCIENCE AND TECHNOLOGY
Faculty of Computing and Informatics
Department of Computer Science
QUALIFICATION: Bachelor of Computer Science
QUALIFICATION CODE: 07BACS
COURSE: Programming 2
DATE: January 2020
DURATION: 3 Hours
LEVEL: NQF 6
COURSE CODE: PRG620S
SESSION: 1
MARKS: 100
SUPPLEMENTARY/SECOND OPPORTUNITY EXAMINATION QUESTION PAPER
EXAMINER(S)
MR MIKE ABIA
MODERATOR:
MR COLIN STANLEY
THIS QUESTION PAPER CONSISTS OF 6 PAGES
(Excluding this front page)
INSTRUCTIONS
Respond to ALL problems in sections A, B and C.
Use the examination script booklet provided.
Each section must be started on a new page.
NUST examination rules and regulations apply.
Follow instructions in the examination script booklet.
Write clearly and neatly.

2 Page 2

▲back to top


SECTION A
[30 marks]
Instructions
Respond to ALL problems in this section.
Select the best option in each of the problems in this section.
Responses must be written in the answer booklet provided.
Marks to each question or part of question are given in [ ].
Problem Al
Which of the following is a property of Event-driven programs?
A. Dynamic
B. Bring challenges
CG Static
D. Unstable
Problem A2
The three software parts of a GUI program are:
A. Windows, Buttons, Mice
B. GUI Components, Graphics, Code
C. GUI Components, Event Listeners, Application Code
D. Frames, Code, Events
Problem A3
Which of the following is an incorrect element ID.
A. intSum
B. 3intSum
C. Int*Sum
D. None of the above
Problem A4
What happens when the following code is compiled and run?
for(int i= 1; i < 3; i++)
for(intj = 3; j >= 1; j--)
assert i!=j : i;
The class compiles and runs, but does not print anything.
The number 1 gets printed with AssertionError
The number 2 gets printed with AssertionError
The number 3 gets printed with AssertionError
Problem A5
The following are all event listener interfaces except
A. ActionListener
B. GuiListener
C. MouseListener
D. WindowListener
[2 marks]
[2 marks]
[2 marks]
[2 marks]
[2 marks]

3 Page 3

▲back to top


Problem A6
What symbol is used inside square brackets to specify that there are two dimensions to the
array being declared?
A. semicolon
B. comma
C. colon
D. period
[2 marks]
Problem A7
What is a container object in GUI programming?
A. Acontainer is another name for an array or vector.
B. Acontainer is any class that is made up of other classes.
C. Acontainer is a primitive variable that contains the actual data.
D. Acontainer is an object like a Frame that has other GUI components
it.
placed inside of
[2 marks]
Problem A8&
A click event on a jbutton has
A. No return type for events
B. String
C. Double
D. Integer
as default return type.
[2 marks]
Problem A9
Which of the following lines will compile without warning or error?
A. char d="d";
B. float f=3.x;
C. int i=34;
D. byte b=257;
[2 marks]
Problem A10
An application can have
A. two
B. three
C. only one
D. All of the above
controls.
[2 marks]

4 Page 4

▲back to top


Problem A11
Which is the container that doesn't contain
components like button, textfield etc?
A. Window
B. Frame
C. Panel
D. Container
title bar and
MenuBars
but it can
have other
[2 marks]
Problem A12
A computer game involves:
A. at least one player who participates to have fun, entertainment, amusement, etc.
B. goals which every player pursues — it stimulates rivalry among the players.
C. rules which define the uniqueness of the game - how the game is played.
D. Allof the above
[2 marks]
Problem A13
Which of Statement A and Statement B is true and which one is false?
Statement A: Sprites can be part of a computer game.
Statement B: Avatars can be part of a computer game.
A. Both Statement A and Statement B are false.
B. Statement A is true and Statement B is false.
C. Both Statement A and Statement B are true.
D. Statement A is false and Statement B is true.
[2 marks]
Problem A14
The capability of a derived class to hide the characteristics of the parent class is called:
A. Overloading
B. Overriding
C. Inheritance
D. Structured programming
[2 marks]
Problem A15
Which of the following is golden rule for interface design?
A. Place the user in control
B. Reduce the user’s memory load
C. Make the interface consistent
D. All of the mentioned
{2 marks]

5 Page 5

▲back to top


SECTION B
[30 marks]
Instructions
e Respond to all problems in this section.
e State whether each of the statements in this section is true or false.
e Maximum score for each correct response on each question or part is given in[ ].
Problem B1
The user interface should move the user into the virtual world of the application.
(2 marks]
Problem B2
‘name’ is an example of a property of an object.
[2 marks]
Problem B3
Each class of controls has the same set of properties.
[2 marks]
Problem B4
When users are involved in complex tasks, the demand on short-term memory can be
significant.
[2 marks]
Problem B5
The statement int arr[ ] = new int[5][ ] can support 5 rows and a variable set of columns in
Java.
[2 marks]
Problem B6
The statement System.out.printIn(8 % 7); will result in 0.
{2 marks]
Problem B7
The design of the interface between two computers is not considered by the Interface
design.
[2 marks]
Problem B8
class School{ } is a complete class declaration.
[2 marks]
Problem B9
Java is another name for C#.
[2 marks]
Problem B10
A good specification should be unambiguous.
[2 marks]
Problem B11
A software might allow a user to interact via mouse movement.
[2 marks]
Problem B12
The statement char d=’d’; is correct in Java.
{2 marks]

6 Page 6

▲back to top


Problem B13
Each control in a program must have its own event-handling methods and these event-
handling methods cannot be shared.
[2 marks]
Problem B14
Menu items are not controls with properties and events.
[2 marks]
Problem B15
Instantiating an object refers to creating an object based on a class.
[2 marks]
SECTION C
[40 marks]
Instructions
e Respond to all problems in this section.
e Maximum score for each correct response on each question or part is given in [ ].
Problem C1
Consider the image below.
Servoy
A.i Please try again
a. Identify two controls in the image.
b. Identify two containers in the image.
c. What is the technical name of the image?
d. Give one instance when you would use it in an application?
e. Can the user pass a custom message to the application using it?
[6 marks]
[6 marks]
[2 marks]
[4 marks]
[2 marks]

7 Page 7

▲back to top


Problem C2
a. Anevent-driven program doesn't have a main() routine that says what will happen
from beginning to end, in a step-by-step fashion. Instead, the program runs in an
event loop. Write down the algorithm for the event loop.
[10 marks]
b. What is the result of running the following code statement?
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillOval(10,10,80,80);
g.setColor(Color.green);
g.fillRect(30,30,40,40);
}
[10 marks]
**%*End of Paper****