8
fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty of Computing and Informatics Department of Computer Science QUALIFICATION: Bachelor of Computer Science, Bachelor of Computer Science in Cyber Security and Bachelor of Informatics QUALIFICATION CODE: O7BACS, 07BA|F LEVEL: 5 COURSE: Programming 1 COURSE CODE: PRG510$ DATE: JULY 2017 SESSION: 2 DURATION: 2 Hours MARKS: 100 SECOND OPPORTUNITY/SUPPLEMENTARY EXAMINATION QUESTION PAPER EXAMINER(S) DR SHAWULU NGGADA MR SIMON MUCHINENYIKA MS NDlNELAGO NASHANDI MR HERMAN KANDJIMI MR HIMEEZEMBI KAHORONGO MODERATOR: MR MIKE ABIA THIS QUESTION PAPER CONSISTS OF 7 PAGES (Excluding this front page) INSTRUCTIONS This paper consists of 3 sections; Section A, B and C. Answer ALL questions in section A and B. Answer ANY 4 questions in section C. Begin each section on a new page. Write clearly and neatly. Number the answers clearly according to question numbers. NP‘WPWF’I‘ Do not use or bring into the examination venue books, programmable calculators, mobile devices and other material that may provide you with unfair advantage.

Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

Embed Size (px)

Citation preview

Page 1: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

fl

I‘IHITIIBIFI UI'iIVERSITY

OF SCIEI'ICE nnD TECHI‘IOLOGY

Faculty of Computing and Informatics

Department of Computer Science

QUALIFICATION: Bachelor of Computer Science, Bachelor of Computer Science in Cyber Security and

Bachelor of Informatics

QUALIFICATION CODE: O7BACS, 07BA|F LEVEL: 5

COURSE: Programming 1 COURSE CODE: PRG510$

DATE: JULY 2017 SESSION: 2

DURATION: 2 Hours MARKS: 100

SECOND OPPORTUNITY/SUPPLEMENTARY EXAMINATION QUESTION PAPER

EXAMINER(S) DR SHAWULU NGGADA

MR SIMON MUCHINENYIKA

MS NDlNELAGO NASHANDI

MR HERMAN KANDJIMI

MR HIMEEZEMBI KAHORONGO

MODERATOR: MR MIKE ABIA

THIS QUESTION PAPER CONSISTS OF 7 PAGES

(Excluding this front page)

INSTRUCTIONS

This paper consists of 3 sections; Section A, B and C.

Answer ALL questions in section A and B.

Answer ANY 4 questions in section C.

Begin each section on a new page.

Write clearly and neatly.

Number the answers clearly according to question numbers.NP‘WPWF’I‘ Do not use or bring into the examination venue books, programmable

calculators, mobile devices and other material that may provide you with unfair

advantage.

Page 2: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

SECTION A — Multiple Choice [40 marks]

This section consists of20 questions

Each correct answer is allocated 2 marks

Written answers should be in upper case and DO NOT provide more than 1 answer to any question.

Which one of these is a problem solving approach?

A.

B

C.

D

Slice through

Dive into

Branch-and—bound

Randomisation

The set of instructions written in a particular programming language is known as:

A.

B

C.

D

Source

program code

original code

source code

Which of the following is true about a statement block in C, C#, C++ and Java?

A.

B

C.

D

It starts with an open curly bracket and ends with a closing curly bracket

It starts with an open square bracket and ends with a closing square bracket

It starts with an open parenthesis and ends with a closing parenthesis

It starts with an open angle bracket and ends with a closing angle bracket

A function is where:

A.

B

C.

D

set of codes for specific operation that may be reused are kept

every code in the Main() could be moved to including declarations

only codes written in Assembly language are kept.

none of the above

Which of the following is not a relational operator in C#

A.

B

C.

D

<>

=>

All of the above

Which of the following best describes a Computer program?

A.

B

C.

D

It is a set of activities to be performed in an event

It is anything fed into the Computer

It is a set of instructions that processes set of inputs to produce set of outputs

None of the above

Page 3: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

7. The variables of a class are referred to as:

A. Private variables

B data members

C. class variables

D field variables

8. The operations of a class are referred to as:

A. methods

B. class statements

C. namespaces

D. snippets

9. Java, C, C++, Delphi, Pascal and C# use the same delimiter at the end of a statement. What is this

delimiter?

A. Colon

B Semicolon

C. Period

D None of the above

10. What is the value of y from the execution of the following set of codes?

sbyte y= 0;

for (int k = 1; k < 16; k= k + 2;)

{

if (k > 5)

{

y=y+k+(k%2);

}

else y = y + k;

}

A. 27

B. 17

C. 30

D.25

11. A person who writes Computer programs is known as a:

A. Coder

B. Debugger

C. Program writer

D. Programmer

Page 4: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

12.

13.

14.

15.

16.

What would be the appropriate thing to do if you would want to track changes to a variable which is

declared in Main() but will be used in other functions?

A. Pass the variable to the function by value

B Move all the related functions into Main()

C. Pass the variable to the function by reference

D None of the above

VVhatistheoutputofthefoHomHngsetofcodes?

bool stop = true;

int k = a;

while (lstop)

{

k = k + 1;

if (k == 3) stop = !(!true);

3

2

0

None of the above.Uosw.>Which of the following is not a logical operator in C#?

.0090 2°“:52°

Which of the following is not a valid C# statement?

A. float price = 7.49;

B byte b = 15;

C. ++i; //assuming i has been earlier declared as int and assigned a value

D i++; //assuming i has been earlier declared as int and assigned a value

What is the value of 2 given the following set of codes?

Float x = 32.8f;

float y = 2.0f;

int 2 = (int) (x / y);

Console.WriteLine(z);

A. 16E

B 16

C. 15

D 164

Page 5: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

17. Why would you prefer the use of while loop rather than do loop in attempting to read the

content of a text file?

A.

B

C.

D

The content needs to be read at least once

To enable testing end of line of the file content in case it is empty

To allow for entire reading of the file content

All of the above

18. Which line among the following set of codes could cause runtime error?

Line 1: string 5 = Console.ReadLine();

Line 2: double cl = double.Par‘se(s);

Line 3: Console.WriteLine(”Value is {0}”, d);

.0090?Line 1

Line 3

Line 2

None of the above

19. Which of the following best describes a list?

A.

B

C.

D

It is a data structure that can grow and shrink and has not fixed size

It is a data structure that can grow and shrink but must have a fixed size

It is data structure that is fixed in size

It only accepts numeric data types

20. Which of the following best describes structures in C#?

A.

B

C.

D

It can contain data attributes and operations

It can contain data attributes but not operations

It can contain data attributes that are of string types only

None of the above

Page 6: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

SECTION B — True or False [20 marks]

This section consists of 10 questions.

Each correct answer is allocated 2 marks.

Answer to each question is either True or False.

Write your answer in full, DO NOT write Tfor True and Ffor False.

In Computing, problem is defined as something that is to be dreaded. {True or False}

A program written in C# for a given problem executes faster than that written in its Assembly

language equivalent. {True or False}

The test value for a switch statement is not limited to a discrete value. {True or False }

It is a good programming practice to end a case statement section of a switch statement block with a

break statement. {True or False }

The Main() is a function that can not return any value to the Operating System.

{True or False}

The following is a valid function . {True or False}

static int MyValue

{

return 6;

}

Every C# program is an Object Oriented Program. {True or False}

An abstract class must be inherited before it could be used. {True or False}

The new keyword is used to copy a class into an Object. {True or False}

10. Black box testing is concerned with investigating the body of the method.

{True or False}

Page 7: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

SECTION C — Structured [40 marks]

This section consists of5 questions.

Answer ANY 4 questions and indicate in your answer booklet which question you are answering.

If you answer more than 4 questions ONLY the first 3 shall be marked.

(a) In one sentence explain what happens in code generation phase of program compilation.

{4 marks}

(b) Briefly explain or give a scenario where the use of Structures (Record) would be ideal, and

explain how a field in a Structure could be accessed. {6 marks}

An arithmetic progression is a sequence in which each differs from the preceding and the next one

by a constant quantity. For instance Z below is an arithmetic progression.

[10 marks]

Z: { 1,4, 7, 10, 13, 16, 19}

Using a do loop, write a program that will sum the above arithmetic progression.

3. What does the following function do? Write out the outputs of the function. [10 marks]

static void WhatDoIDo(){

str‘ing myStr‘ingl = ""5

string myStr‘ingZ = "";for (int i = e,- i <= 29; i++){

if ((i % 2) == 6)

{

myStr‘ingl = myStringl + i.ToStr‘ing() +"

",-

}else

{

myStr‘ingZ = myStringZ + i.ToStr‘ing() +"

";

}

}

Console.writeLine(myStr‘ing1)3

Console.writeLine(myString2)3}

4. Answer the following questions. [10 marks]

(a) Explain briefly what the following terms mean. {4 marks}

(i) Superclass

(ii) Subclass

(b) Assessment is a class with totalMarks as data member of type double and also mode as a

data member of type string. Similarly, Examination is a class with paperType as a string data

member. Define the two classes using the given information only to demonstrate the notion

of superclass and subclass. {6 marks}

Page 8: Computing Informatics - exampapers.nust.naexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · fl I‘IHITIIBIFI UI'iIVERSITY OF SCIEI'ICE nnD TECHI‘IOLOGY Faculty

5. Answer the following questions. [10 marks]

(a) Differentiate between the keywords virtual and override in C#. {6 marks}

(b) Assuming Student is a Subclass of Person and SignUp() is an overridden method. This means

both Person and Student have implementation of the SignUp() method. Study the following code.

Person p = new Student();

p-SignUp();

Which of the class methods will be executed and why? {4 marks}

End of Question Paper