Cosc 112 Final MCQ
Cosc 112 Final MCQ
NO
[Q
Name:……………………………………………..
Matric. No:………………………………………
UESTION PAPER] TITLE:
INTRODUCTION TO COMPUTER SCIENCE & PROGRAMMING II(COSC112)
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
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
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