8
I'IHITIIBIH UI'IIVERSITY 0F SCIEI’ICE HI‘ID 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, O7BAIF LEVEL: 5 COURSE: Programming 1 COURSE CODE: PRGSlOS DATE:JUNE 2017 SESSION: 1 DURATION: 2 Hours MARKS: 100 FIRST OPPORTUNITY EXAMINATION QUESTION PAPER EXAMINER(S) DR SHAWULU NGGADA MR SIMON MUCHINENYIKA MS NDINELAGO 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. Do not use or bring into the examination venue books, programmable NR‘P‘PWNH calculators, mobile devices and other material that may provide you with unfair advantage.

Faculty Computing and Informatics Departmentexampapers.nust.na/greenstone3/sites/localsite/collect/exampape... · I'IHITIIBIH UI'IIVERSITY 0F SCIEI’ICE HI‘ID TECHI'IOLOGY Faculty

  • Upload
    doannhi

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

I'IHITIIBIH UI'IIVERSITY

0F SCIEI’ICE HI‘ID 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, O7BAIF LEVEL: 5

COURSE: Programming 1 COURSE CODE: PRGSlOS

DATE:JUNE 2017 SESSION: 1

DURATION: 2 Hours MARKS: 100

FIRST OPPORTUNITY EXAMINATION QUESTION PAPER

EXAMINER(S) DR SHAWULU NGGADA

MR SIMON MUCHINENYIKA

MS NDINELAGO 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.

Do not use or bring into the examination venue books, programmableNR‘P‘PWNHcalculators, mobile devices and other material that may provide you with unfair

advantage.

SECTION A — Multiple Choice [40 marks]

This section consists of 20 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 of the following is true about abstraction?

A.

B

C.

D

It uses certain well-known characteristics ofa problem to produce an approximate solution.

it breaks problem into simpler form and then conquers it.

It is a function in a programming language

it describes the properties or attributes and the behaviour of the problem

Which of the following languages does not use an interpreter for translation?

A.

B

C.

D

Prolog

BASIC

Ada

Javascript

Which one of the following is true about C#?

A.

B

C.

D

It is derived from Assembly language

It does not support Web programming

it is only applicable to Scientific and Engineering applications

it could be used to develop Mobile apps for iOS, Android and Windows Phone

Which one of the following is true about C#?

A.

B

C.

D

It has basis in Java

It is derive from C and C++

It is the same as C++ in everything, what separates them is just the names.

It is the language of the .NET that was developed from ground up.

A line of code in C# or any other programming language is called a:

A.

B

C.

D

Code line

Statement

Source line

Program line

Which of the following is not an approach to problem solving

A.

B

C.

D

Streaming

Abstraction

Divide—and-conquer

Reduction: transform-and-conquer

7. Which of the following is not a high-level language?

A. C++

B Ada

C. Delphi

D None of the above

8. Which of the following languages does not use a compiler for translation?

A. Prolog.

B C++

C. C

D C#

9. A function signature refers to:

A. its access specifier, name and argument list

B its return type, access specifier, name and argument list

C. its name and argument list

D its return type, access specifier and name

10. What is the return value of the following function ifx = 5.3 and y= 4.2?

static float Add(float x, float y)

{

float z = 6;

return 2;

z = x + y;

return 2;

}

A. 95

B

C.

D. 05

11. Which of the following best describes the advantage of restricting access to members of an Object?

It helps preserve memory on the heap

B. It helps prevent the misuse of an Object

C. It helps reduce the number ofObjects created

D. None of the above

12.

13.

14.

15.

16.

17.

18.

Which of the following is not an access modifier in C#

A. protected

B private

C. public

D partial

Which of the following is a logical operator in C#

A. \\

B AND

C. &&

D NOT

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

A. l=

B

C. =<

D None of the above

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

A. float f = 10.7f;

B string 5 = "”,'

C. int c = 5.0;

D None of the above

Which of the following has same evaluation as ((8 > 4 ) && (4 < 8 )) && (5 != 5)

A. (8>4)&&l((4<8)&&(5!=5))

B ((8>4)||(5!=5))&&(4<8))

C. !((8>4)&&(4<8))||(5!=5)

D None of the above

Which of the following is not a primitive data type?

A. sbyte

B ulong

C. struct

D decimal

What data type will be appropriate for counting the number of students not more than 200?

A. byte

B. int

C. sbyte

D float

19. Which of the following is not a method related to text files in C#?

ReadLine()

B. CbseO

C. WriteLine()

D. None of the above

20. Which ofthe following lines will cause the following set of C# codes not to compile?

Unelzstring s = Console.ReadLine();

Une2:sbyte b = sbyte.Parse(Console.ReadLine());

Line3zint = b + s;

A. Line 1

B. Line 2

C. Line 3

D. None of the above

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 F for False.

Heuristics as an approach to problem solving is based on well-established knowledge in the problem

domain {True or False}

The following expression evaluates to true {True or False}

!(3 <= 5) II (0 != 2)

A List data type is another name for Array data type {True or False }

An if statement must have a corresponding else statement always irrespective of the circumstances

{True or False}

A change to a function argument which is passed by value will be reflected in the calling code.

{True or False}

The following code has an error. {True or False}

Console.WriteLine(“Adding 2 numbers”);

double result = O;

Add(4.5, 6.0, result);

static void Add(double x, double y, ref double result)

{

result = x + y;

return result;

A static data member of operation of a Class can be used without necessarily creating an Object of

the Class. {True or False}

A C# program must call a Constructor when creating an Object even when a Constructor is not

explicitly defined by the programmer. {True or False}

The default access mode of a method whose access modifier has not been specified is protected.

{True or False}

10. White box testing investigates inputs and outputs to methods (if any). {True or False}

SECTION C — Structured [40 marks]

This section consists of5 questions.

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

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

(a) In Compilation, what do you understand by intermediate code generation?

{4 marks}

(b) Give 3 distinct advantages of Assembly language over Machine language.

{6 marks}

The following are first names of some individuals. [10 marks]

Mary, John, Paul, Maria and Stepanie

(a) Demonstrate how the above names could be initialised using an array at declaration in the

order in which they appear above. {6 marks}

(b) Sequel to your declaration in (a) above, ifx = 13,y = 3, z = S andj = ((int) ((2*

x) / y)) % 2, what is the value ofj and what is the name at array index j?

{4 marks}

Assuming y is an integer and similarly x is an integer which has been given a value previously, re-

write the following codes using a switch statement. [10 marks]

if(x==5)y=++x+2;

elseif(x==6)y=x+2;

else if (x == 4) y= 2*x;

else y=

x;

Answer the following questions. [10 marks]

(a) What is the significance ofa Constructor? {3 marks}

(b) What could you use Constructor for OR how would you take advantage of a Constructor?

{3 marks}

(c) What happens when an Object of a Class is created and the Class does not contain a

Constructor? {4 marks}

5. Answer the following questions.

(a)

(b)

Explain the follow chart in terms of Classes

Employee

A

AdminStaff

When would you use method overriding?

End of Question Paper

[10 marks]

{6 marks}

TechnicalStaff

{4 marks}