You are on page 1of 7

FINAL EXAMINATION

PROGRAMME Bachelor of Commerce in Information and Technology Management

MODULE Informatics 1B

YEAR One (1)

INTAKE July 2016

DATE 31 May 2017

TIME 14h00 – 17h00

DURATION 3 hours

TOTAL MARKS 100

INSTRUCTIONS TO THE CANDIDATE

1. Questions must be attempted in the answer book provided.


2. All queries should be directed to the invigilator; do not communicate or attempt to communicate with any
other candidate.
3. You have THREE HOURS to complete this paper. You are not allowed to leave the examination room within
the first hour and in the last 15 minutes of this examination.
4. This is a CLOSED BOOK examination.
5. Read ALL instructions carefully.

m
Answer ALL questions.

QUESTION 1 (20 Marks)

Choose the most appropriate answer. Write down numbers 1.1 to 1.20 in your answer book and next to each number
write the letter that represents the correct answer. E.g. 1.21 A

1.1 Temporary memory is stored in a computer’s:

A. Random Access Memory (RAM)


B. Read Only Memory (ROM)
C. Hard disk
D. Flash drive

1.2 Which one of the following is not an internal data structure?

A. Arrays
B. Linked lists
C. Databases
D. Queues

1.3 Which of the following is correct Java code?

A. int[10] arr;
B int arr[10];
C. int arr = new int[10];
D. int[] arr = new int[10];

1.4 The process of separating the logical properties of the data from its implementation is called:

A. Methods
B. Statistics
C. Data abstraction
D. Stacking data

1.5 A data item that can only be used within a method is called:

A. A local variable
B. An instance variable
C. A global variable
D. A private variable

1.6 A constructor:

A. Must have the same name as the class it is declared within.


B. Is used to create objects.
C. May be declared private
D. A, B and C
1
m
1.7 Consider the following code snippet:

public class MyClass{


public MyClass(){/*code*/}
// more code...
}
To instantiate MyClass, you would write?

A. MyClass mc = new MyClass();


B. MyClass mc = MyClass();
C. MyClass mc = MyClass;
D. MyClass mc = new MyClass;

1.8 A ________ is a collection of data items where each item is linked to its successor.

A. Linked list
B. Element link
C. Constant references
D. Node contents

1.9 The main advantage of temporary memory is that:

A. It is effective
B. It is fast
C. It is external
D. It is extensive

1.10 Which option below does not represent permanent storage?

A. Databases
B. Sequential files
C. Direct files
D. Arrays

1.11 Data structures that are created and used from within your program are referred to as:

A. Internal Data Structures


B. External Data Structures
C. Variables
D. Objects

2
m
1.12 Which of the following statements are valid array declarations?

(i) int number ();


(ii) float average [];
(iii) double [] marks;
(iv) counter int [];

A. (i)
B. (ii) & (iii)
C. (i) & (iii)
D. (iv)

1.13 The relationship between two classes that is based on the aggregation relationship:

A. Composition
B. Encapsulation
C. Information hiding
D. Notation

1.14 A method is called, and before it completes, that method calls a second one, the second calls a third before
completing and so forth, this is referred to as:

A. Stacking
B. Method chaining
C. Queues
D. Popping

1.15 What will be the output?

public class Test{


public static void main(String[] args){
int[] x = new int[3];
System.out.println("x[0] is " + x[0]);
}
}

A. The program has a compile error because the size of the array wasn't specified when declaring the array.
B. The program has a runtime error because the array elements are not initialized.
C. The program runs fine and displays x[0] is 0.
D. The program has a runtime error because the array element x[0] is not defined.

3
m
1.16 What is the result of compiling and running the following code?

public class Test{


public static void main(String[] args){
int[] a = new int[0];
System.out.print(a.length);
}
}
A. 0
B. Compilation error, arrays cannot be initialized to zero size.
C. Compilation error, it is a.length() not a.length
D. None of the above

1.17 In Java arrays are:

A. objects
B. object references
C. primitive data type
D. None of the above

1.18 A class is a template for:

A. method
B. object
C. variable
D. queue

1.19 The add (5) method _____________________.

A. Inserts the number 5 item to the end of the list.


B. Inserts the number 5 at the beginning of the list.
C. Sets a value at the 5th position of the list.
D. References the value at the 5th position in the list.

1.20 Java will automatically define a constructor:

A. If the programmer does not define a default constructor for a class


B. If the programmer does not define any constructors for a class
C. The program refers to a constructor with no parameters
D. For every class defined in a program

4
m
QUESTION 2 (20 Marks)

State whether the following statements are True or False. Write down the question number and the word True or False
next to it. E.g. 2.21 True

2.1 Temporary data is stored in the memory of the computer.


2.2 Information is described as facts and statistics not in any particular order.
2.3 In Java, the array index starts at 1.
2.4 Sequential files are faster than Indexed files for storing and retrieving data.
2.5 Unique reference numbers that identify each entry uniquely is called a primary key.
2.6 The type of elements in an array is called the base type.
2.7 Encapsulation is the process of defining a class that has no public methods.
2.8 Objects enable reuse of software components.
2.9 Pull operation is a stack operation.
2.10 Permanent data remains in existence even after the application which created it is closed.
2.11 A method can have both a variable length formal parameter and other formal parameters.
2.12 Constructors have return type void.
2.13 A direct access file is a type of file in which each data can be accessed sequentially.
2.14 A LinkedList in Java has a fixed length.
2.15 Each element in a LinkedList is known as a “node”.
2.16 Get methods are used to return the values of an object’s attributes.
2.17 A class may have more than one constructor.
2.18 The ability of a family of related classes to each implement their own version of a method is an example of
polymorphism.
2.19 Call centre phone systems uses a Stack structure to hold people in line.
2.20 An efficient way to store, manipulate and retrieve large amounts of data is databases.

QUESTION 3 (20 Marks)

3.1 Differentiate between a Stack and a Queue structure. (4 marks)


3.2 Describe the operations that can be done on a Stack structure. (6 marks)
3.3 Discuss the practical applications of Queues. (6 marks)
3.4 The Queue program below has some errors, rewrite the program correctly: (4 marks)
import java.util.Queue;
import java.util.LinkedList;
Public class QueueTest
public static main (String [] args){
Stack q1 = new LinkedList();
q1.add(3*4);
q1.add(7+8);
q1.remove();
System.out.println(q1.print); }
}

5
m
QUESTION 4 (20 Marks)

4.1 Differentiate between an array and a linked list. (5 marks)


4.2 List FIVE (5) methods used in a linked list. (5 marks)
4.3 Write a Java program called ArrayExample that creates integer array called arr that stores the following
numbers (24,10,65,12,56). Use an appropriate loop to add the elements of the array together. Using a
System.out statement display the total. (10 marks)

QUESTION 5 (20 Marks)

5.1 What are the disadvantages of sequential files? (4 marks)


5.2 List THREE (3) advantages and THREE (3) disadvantages of direct access files? (6 marks)
5.3 Discuss the concept Data Abstraction. (5 marks)
5.4 Differentiate between data and information. (5 marks)

END OF PAPER

6
m

You might also like