C & C++ Programming Multiple Choice Questions - Set 49

1.       What will be the values of x, m and n after the execution of the following statements?
int x, m, n;
m = 10;
n = 15;
x = ++m + n++;
(A) x=25, m=10, n=15
(B) x=26, m=11, n=16
(C) x=27, m=11, n=16
(D) x=27, m=10, n=15
Answer: B
2.       Which of the following will produce a value 10 if x = 9.7?
(A) floor(x)
(B) abs(x)
(C) log(x)
(D) ceil(x)
Answer: D
3.       The major goal of inheritance in c++ is:
(A) To facilitate the conversion of data types.
(B) To help modular programming.
(C) To extend the capabilities of a class.
(D) To hide the details of base class.
Answer: C
4.       Consider the following class definitions:
class a
{
};
class b: protected a
{
};
What happens when we try to compile this class?
(A) Will not compile because class body of a is not defined.
(B) Will not compile because class body of b is not defined.
(C) Will not compile because class a is not public inherited.
(D) Will compile successfully.
Answer: D
5.       Which of the following expressions is illegal?
(A) (10|6).
(B) (false && true)
(C) bool (x) = (bool)10;
(D) float y = 12.67;
Answer: C

6.       The actual source code for implementing a template function is created when
(A) The declaration of function appears.
(B) The function is invoked.
(C) The definition of the function appears.
(D) None of the above.
Answer: B
7.       An exception is caused by
(A) a runtime error.
(B) a syntax error.
(C) a problem in the operating system.
(D) a hardware problem.
Answer: A
8.       Which of the following shows the correct hierarchy of arithmetic operations in C ?
(A) / + * -
(B) * - / +
(C) + - / *
(D) * / + -
Answer: D
9.       What will be the value of d if d is a float after the operation d = 2 / 7.0?
(A) 0
(B) 0.2857
(C) Cannot be determined
(D) None of the above
Answer: B
10.    A constructor
(A) Constructs new data type
(B) Enables the initialization of an object as it is created
(C) Obtain memory for a new variable
(D) None of the above
Answer: B


Post a Comment

0 Comments