0% found this document useful (0 votes)
29 views

INFORMATICS 1B NEW - PR

The document provides instructions for a final examination for a Bachelor of Commerce in Information and Technology Management program. It outlines the module, year, intake, date, time, duration, total marks, and instructions to the candidate. The examination consists of 3 questions worth 20 marks each, testing the candidate's knowledge of arrays, linked lists, stacks, queues and other data structures.

Uploaded by

Tracy-lee Jacobs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

INFORMATICS 1B NEW - PR

The document provides instructions for a final examination for a Bachelor of Commerce in Information and Technology Management program. It outlines the module, year, intake, date, time, duration, total marks, and instructions to the candidate. The examination consists of 3 questions worth 20 marks each, testing the candidate's knowledge of arrays, linked lists, stacks, queues and other data structures.

Uploaded by

Tracy-lee Jacobs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

FINAL EXAMINATION

PROGRAMME Bachelor of Commerce in Information and Technology Management

MODULE Informatics 1B

YEAR One (1)

INTAKE July 2017

DATE 21 April 2018

TIME 09h00 – 12h00

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.

ds
Answer ALL questions.

QUESTION 1 (20 Marks)


Choose the correct option. Write down the question number and the correct answer next to it. E.g. 1.21 A

1.1 Which of the following statements are valid array declaration?

i) int number();
ii) float average[];
iii) double[] marks;
iv) counter int[];
A) i only
B) ii and iii
C) iv
D) i and iii

1.2 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 initialised to zero size.
C) Compilation error, it is a.length() not a.length
D) None of the above

1.3 What will be the output?

public class Example {


public static void main (String [] args){
int [] x = new int [5];
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 initialised.
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.

1.4 Which one of the following is not a permanent storage of data?

A) Databases
B) Objects
C) Sequential files
D) Indexed files

ds 1
1.5 What is the return type of constructors?

A) int
B) float
C) void
D) None of the above

1.6 An efficient and powerful way to store, manipulate and retrieve large amounts of data is:

A) Files
B) Records
C) Databases
D) Storage

1.7 Which one of these operators is used to allocate memory to an array variable in Java?

A) malloc
B) alloc
C) new
D) new malloc

1.8 Given the declaration Circle x = new Circle (); which of the following statements is most accurate?

A) x contains an int value


B) x contains an object of the Circle type
C) x contains a reference to a Circle object
D) You can assign an int value to x

1.9 Methods that are automatically executed when an object of a given type is created is referred to as:

A) Classes
B) Constructors
C) Methods
D) Constants

1.10 One benefit of encapsulation is:

A) the implementation of the class will be smaller.


B) the implementation can be changed without changing programs that use the class.
C) the interface of the class will be smaller.
D) the interface can be changed without changing programs that use the class.

1.11 The name of the constructor:

A) can be any legal identifier


B) must include the name of the package
C) will always be the word new
D) will always be the same as the name of the class

ds 2
1.12 Which statement below will legally declare, construct and initialise an array?

A) int [] mylist = {“1”,”2”,”3”};


B) int [] mylist = (5,8,2);
C) int mylist [] [] = {4,9,7,0};
D) int mylist [] = {4,3,7};

1.13 The LinkedList method, set (2,34) does the following:

A) replaces the value 34 at index 2 in the list.


B) inserts the number 2 next to 34 in the list
C) replaces the value 2 at index 34 in the list
D) adds 2 to 34 and inserts the total to the list

1.14 The lowest index that can be used in an array is:

A) zero
B) one
C) determined by the array declaration
D) changed as the program runs

1.15 Temporary memory is stored in a computers:

A) Random Access Memory (RAM)


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

1.16 Data can be described as:

A) processed information
B) facts and statistics collected together for reference or analysis
C) ordered records
D) meaningful facts

1.17 A collection of data items where each item is linked to its successor is called:

A) Elements
B) Indexes
C) Linked Lists
D) Arrays

ds 3
1.18 What is the output of the following piece of code?

public class array {


public static void main(String args[]) {
int []arr = {1,2,3,4,5};
System.out.println(arr[2]);
System.out.println(arr[4]); }}
A) 3 and 5
B) 5 and 3
C) 2 and 4
D) 4 and 2

1.19 Which of the following applications may use a stack?

A) A parentheses balancing program.


B) Tracking of local variables at run time.
C) Compiler Syntax Analyzer.
D) All of the mentioned

1.20 A linear list of elements in which deletion can be done from one end (front) and insertion can take
place only at the other end (rear) is known as a:

A) Queue
B) Stack
C) Tree
D) Linked list

ds 4
QUESTION 2 (20 Marks)
Determine if the following statements are True or False. Write down the question number and the correct
answer next to it. E.g. 2.21 True

2.1 Once an array is created, it is of flexible size.


2.2 All objects of the same class have the same data values.
2.3 Methods are used to implement the behaviours of the object.
2.4 Sequential files work a bit like songs on a cassette tape.
2.5 The following statement declares the size of the array: int [] array = {10};
2.6 A class is a template for an object.
2.7 Each element in the array is referenced by an alphabet.
2.8 If the compiler encounters errors in the Java code, it will stop compiling.
2.9 The name of the file must be different to the class name.
2.10 The constructor method must always have at least one parameter.
2.11 A variable of class type does not store an object of that class.
2.12 The behaviour of an object is what you can do to it and what it can do.
2.13 Java automatically creates a class if the class does not possess one.
2.14 The constructor is called when an object is created.
2.15 Array elements contain random values, until you assign values to them.
2.16 The term composition refers only to music classes.
2.17 A common operation on an array is called iterating.
2.18 A queue can be implemented in Java as a LinkedList.
2.19 A primary key is a duplicate identifier for each record in a data file.
2.20 The keyword private is used to specify that the attribute or method to which it refers is only visible within the
containing class.

ds 5
QUESTION 3 (20 Marks)

3.1 Explain the following Linked list methods:

3.1.1 add (5) (2 marks)


3.1.2 add (2,5) (2 marks)
3.1.3 addFirst (5) (2 marks)
3.1.4 remove (3) (2 marks)
3.1.5 set (2,34) (2 marks)

3.2 Implement the following stack operations into a Java program called StackTest; name the stack s1. (10 marks)

Plan: Empty stack


push(“Book A”)
push(“Book B”)
push(“Book C”)
push(“Book D”)
push(“Book E”)
pop()
print peek()
pop()
pop()
print peek()

QUESTION 4 (20 Marks)

4.1 Explain the concept of Arrays. (5 marks)

4.2 Write java code to create an array called hobbies[] that has the following elements: {swimming,
reading, hiking, soccer, fishing and dancing}. Using a loop, output all the elements of the array.
(15 marks)

QUESTION 5 (20 Marks)

5.1 Differentiate between data and information. (3 marks)

5.2 Explain the importance of data structures (8 marks)

5.3 List the advantages and disadvantages of temporary and permanent data. (4 marks)

5.4 Besides variables, there are numerous other ways to store information in temporary storage. List these
mechanisms. (5 marks)

END OF PAPER

ds 6

You might also like