0% found this document useful (0 votes)
138 views3 pages

Cosc 112 Final MCQ

This 3-page document appears to be a 50 question exam covering introductory computer science and programming concepts in C++. It includes multiple choice questions testing knowledge of data types, functions, operators, control structures, classes and objects. The exam is divided into 3 pages with questions 1-17 on page 1, questions 18-33 on page 2, and questions 34-50 on page 3. Students are instructed to attempt all 50 questions within the 2 hour time limit.

Uploaded by

Alex Uchenna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views3 pages

Cosc 112 Final MCQ

This 3-page document appears to be a 50 question exam covering introductory computer science and programming concepts in C++. It includes multiple choice questions testing knowledge of data types, functions, operators, control structures, classes and objects. The exam is divided into 3 pages with questions 1-17 on page 1, questions 18-33 on page 2, and questions 34-50 on page 3. Students are instructed to attempt all 50 questions within the 2 hour time limit.

Uploaded by

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

Page 1 of 3 PAPER REF.

NO
[Q
Name:……………………………………………..
Matric. No:………………………………………
UESTION PAPER] TITLE:
INTRODUCTION TO COMPUTER SCIENCE & PROGRAMMING II(COSC112)

SEMESTER EXAM: 2nd SESSION: 2019/2020 Time Allowed: 2 Hours


EXAMINERS: Idowu, S.A, Adekola, O.,Akande O. Omotunde, A, Ebiesuwa O.
INSTRUCTION: Attempt 50 Questions

2) Which of the following is NOT a primitive data


type in C:

(a) float (b) char (c) array (d) int

3). Assuming variable num starts with value 10, what 12). What is the output of the flowing code chunk:
would the following code fragment print out? {
int num = 10; int a = 5;
cout << num - -; int b = 10;
cout << (a > b? a : b);
(a) 9 (b) 10 (c) 11 (d) nil }
(a) 5 (b) 10 (c) 15 (d) 50
4).If int sum = 21 and int val = 3. What is the final value 13). ____ & ____ are the two ways by which
of sum from the expression: arguments can be passed into a function when it is
sum+=val called.
(a) 19 (b) 7 (c) 24 (d) 63 (a) parameter passing & value passing (b) pass-by
value & pass-by-reference (c) pass-by-value &
pass-by-variable (d) data type & pass-by-reference

7). A function prototype specifies--------------------,


------------------- and -------------------------------
(a) function and parameter (b) function name and
parameter (c) function name and parameter list
(d) function call and function definition
8) Keyword used in defining a symbolic 17) A function returning no value is declared as:
constant in C++ programing is: ……………
(a) const (b).#define (c) a and b (d) <iostream> (a) void (b) static (c) return (d) default

19). Two functions having the same signatures but 27). What is the result of the following code listing :
different implementation as a C++ feature is called: int item = 10;
int wages(double a){…} int *Ptr = &item;
int wages(double b){…} cout<<” \nThe output: ”<<(*Ptr + 10)<<endl;

(a) inheritance (b) overloading (c) overriding (a) 100 (b) 10 (c) 20 (d) *Ptr + 10
(d) encapsulation

20) A helper function known to and seen by only


members of its class is declared as:
(a) protected (b) local (c) private (d) public
Page 2 of 3 PAPER REF. NO
21) What happens to a line of code written after return
statement…………………………….
(a) unreachable (b) commented (c) deleted (d)
returned
22) What is the output if integer values 2 is received by 30) . In the following code, what is the output from
variable choice in the following code: cout if cin is used to read in the following string data:
cin>>choice; “object think”
switch(choice){
Case 1: cout<<"Hey "; break; #include <iostream>
Case 2: cout<<" How "; using namespace std;
Case 3: cout<<" Coding”; break; int main()
default: cout<<"\n Out of Range";
{
}
string name;
(a) Hey (b) How (c) Coding (d) How Coding cin >> name;
cout <<name;
}

(a) object (b) think (c) object think (d) o

23). Considering the following variable and pointer


initialization, what statement would print the value of
count?
int count = 25;
int *countPtr = &count;
(a) cout<< countPtr; (b) cout<< &countPtr;
(c) cout<<*countPtr; (d) cout<<countptr;
24) Consider the following array definition: 32) The following are common to both C and C++
char school[ ] = "Babcock"; except:
What is the element in school[2]………
(a) a (b) b (c) B (d) A (a) const (b) break (c) continue (d) bool
25). What is wrong with the following function call: 33) How do you describe the following operation in the
code block:
int costOfall(int x, string y, double z) //declaration { temp = x;
costOfall(20, 34.8, “Gowon Estate”); // function call x= y;
y = temp; }
(a) parameter type (b) function type (a) assignment (b) insertion
(c) function name (d) return type (c) swap (d) override
26). What is the operator for logical-and? 34) What does the following declaration/initialization
(a) && (b) & (c) AND (d) || also imply: double blend(32.5)
(a) double blend = 32.5; (b) double 32.5 = blend;
(c) double blend; (d) blend = 32.5;
35) Consider the following code chunk and find the 44) Write a C++ line of code to compute the value of
value of quotient: 2.5 raised to the power 3 using function pow:
int dividend, divisor, quotient; (a) p = pow(2.5, 3); (b) p = pow(3, 2.5);
dividend = 7; (c) p = power(2.5, 3); (d) p = power(3, 2.5);
divisor = 2;
quotient = dividend / divisor;
(a) 3.5 (b) 3.0 (c) 3 (d) 3.50

36) If a discount of 5% is given for buying 45) Which of the following is an address operator in
mayonnaise, what is the logic for amount paid: C++?
(a) amtPaid = totalCost – 5 * totalCost (a) * (b) & (c) _ (d) %
(b) amtPaid = totalCost – 0.5 * totalCost
Page 3 of 3 PAPER REF. NO
(c) amtPaid = totalCost – 0.05 * totalCost
(d) amtPaid = totalCost – 5 / totalCost
37) What is the output of the following: 46) What are the actual parameters in C++?
string name1 = "Tom"; a) Parameters with which functions are called
string name2 = "Bayo"; b) Parameters which are used in the definition of a
name2 = name1 + name2; function
cout<<name2; c) Variables other than passed parameters in a
(a) Tom Bayo (b) TomBayo (c) Bayo Tom function
(d) TomTom d) Variables that are never used in the function
38) If y is 10, what is the outcome of the following 47) Which of the following is called insertion
expression when evaluated: operator?
!( ( y < 3) | | ( y > 7) ) (a) << (b) >> (c) > (d) <
(a) true (b) false (c) both (d) nil
39) Consider the following enumerated type, what is 48) C++ is ______________
the value of element FIVE: a) procedural programming language
enum MyEnum{ONE = 17, TWO, THREE, b) object oriented programming language
FOUR = -2, FIVE}; c) functional programming language
(a) -2 (b) -1 (c) 0 (d) 1 d) both procedural and object oriented programming
language
40) What is the final value of sum in the following 49) Which of the following is the scope resolution
code chunk operator?
{ int n, sum = 0; (a) . (b) * (c) :: (d) ~
for (n = 1; n <= 3 ; n++,n++)
sum = sum + n;
}
(a) 4 (b) 9 (c) 120 (d) 3
41) what is the value in candyPerPerson: 50) Identify the user-defined types from the
int totalCandy = 9, numberOfPeople = 4; following?
double candyPerPerson; a) enumeration
candyPerPerson = static_cast<double>(totalCandy) b) classes
/ numberOfPeople; c) both enumeration and classes
(a) 2 (b) 2.25 (c) 2.0 (d) 1 d) int
42) State a benefit of inheritance in Object Oriented
programming paradigm:
(a) information hiding (b) encapsulation
(c) reusability (d) objects
43) C ++ language was developed by:
(a) Dennis Ritchie (b) Charles Babbage
(c) Ada Augusta (d) Bjarne Stroustrup

You might also like