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

1.       The pure virtual function represents the ..................
(A) inheritance             (B) overloading
(C) overriding               (D) interface
Answer: D
2.       Which of the following is not a correct variable type?
(A) float              (B) real.
(C) switch          (D) double
Answer: C
3.       Which of the following is the correct operator to compare two variables?
(A) :=                  (B) v
(C) equal           (D) = =
Answer: D
4.       Which of the following is the boolean operator for logical-and?
(A) &                   (B) &&
(C) |                    (D) |&
Answer: B
5.       The directives for the pre-processors begin with ...................
(A) ampersand symbol (&)
(B) b. two Slashes (//)
(C) number Sign (#)
(D) less than symbol (<)
Answer: C

6.       A continue statement causes execution to skip to ...................
(A) the return 0; statement.
(B) the first statement after the loop.
(C) the statement following the continue statement.
(D) the next iteration of the loop.
Answer: D
7.       In a group of nested loops, which loop is executed the most number of times?
(A) The outermost loop.
(B) The innermost loop.
(C) All loops are executed the same number of times.
(D) Cannot be determined without knowing the size of the loops bottom of form.
Answer: B
8.       Each pass through a loop is called a/an ...............
(A) enumeration          (B) iteration
(C) culmination                        (D) pass through
Answer: B
9.       Regarding #define which of the following statement is false?
(A) it is not C++ statement but the directive for the pre-processor.
(B) this does not require a semicolon at the end of line.
(C) it is a C++ statement that declares a constant in C++.
(D) none of the above.
Answer: C
10.    What will be the output of the following code segment, if any?
myfunc ( struct test t) {
strcpy(t.s, “world”);
}
main( ) {
struct test { char s[10]; } t;
strcpy(t.s, “Hello”);
printf(“%s”, t.s);
myfunc(t);
printf(“%s”, t.s);
}
(A) Hello Hello                         (B) world world
(C) Hello world                         (D) the program will not compile
Answer: D
Explanation:
The program will not compile because undefined symbol s for myfunc( ) function. Structure should be defined before the main and the function where it is called.


Post a Comment

0 Comments