Pages

Thursday, January 13, 2011

(MCQs) - Multiple Choice Questions - MCQs from C++ set - 4

Question 1

In an assignment statement
a=b;
Which of the following statement is true?
a.    The variable a and the variable b are equal.
b.    The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a
c.    The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a
d.    The value of variable a is assigned to variable b and the value of variable b is assigned to variable a.

Question 2

All of the following are valid expressions in C++
a  =  2 + (b = 5);
a  = b = c = 5;
a  = 11 % 3
a.    True
b.    False


Question 3:

To increase the value of c by one which of the following statement is wrong?
a.    c++;
b.    c = c + 1;
c.    c + 1 => c;
d.    c += 1


Question 4:

When following piece of code is executed, what happens?
b = 3;
a = b++;
a.    a contains 3 and b contains 4
b.    a contains 4 and b contains 4
c.    a contains 4 and b contains 3
d.    a contains 3 and b contains 3


Question 5:

The result of a Relational operation is always
a.    either True or False
b.    is less than or is more than
c.    is equal or less or more
d.    All of these


Question 6:

Which of the following is not a valid relational operator?
a.    ==
b.    =>
c.    >=
d.    >=

Question 7:

What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
A. 10
B. 9
C. 0
D. 1


Question 8:

When does the code block following while(x<100) execute?
A. When x is less than one hundred
B. When x is greater than one hundred
C. When x is equal to one hundred
D. While it wishes


Question 9:

Which is not a loop structure?
A. for
B. do while
C. while
D. repeat until


Question 10:

How many times is a do while loop guaranteed to loop?
A. 0
B. Infinitely
C. 1
D. Variable




Answers



1.    b. The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a
2.    a. True
3.    c. c + 1 => c;
4.    a. a contains 3 and b contains 4
5.    a. either True or False
6.    b. =>
7.    A. 10
8.    A. When x is less than one hundred
9.    D. Repeat Until
10.    C. 1