Programming In C++ MCQs Set-9

1. A class defined within another class is:
  • Nested class
  • Inheritance
  • Containership
  • Encapsulation
2. 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++;
  • x=25, m=10, n=15
  • x=26, m=11, n=16
  • x=27, m=11, n=16
  • x=27, m=10, n=15
3. Which of the following will produce a value 10 if x = 9.7?
  • floor(x)
  • abs(x)
  • log(x)
  • ceil(x)
4. The major goal of inheritance in c++ is:
  • To facilitate the conversion of data types.
  • To help modular programming.
  • To extend the capabilities of a class.
  • To hide the details of base class.
5. Consider the following class definitions: class a { }; class b: protected a { }; What happens when we try to compile this class?
  • Will not compile because class body of a is not defined.
  • Will not compile because class body of b is not defined
  • Will not compile because class a is not public inherited
  • Will compile successfully.
6. Which of the following expressions is illegal?
  • (10 6).
  • (false && true)
  • bool (x) = (bool)10;
  • float y = 12.67;
7. The actual source code for implementing a template function is created when
  • The declaration of function appears.
  • The function is invoked.
  • The definition of the function appears.
  • None of the above.
8. An exception is caused by
  • a runtime error.
  • a syntax error.
  • a problem in the operating system.
  • a hardware problem.
9. Which of the following statements are true in c++?
  • Classes can not have data as public members.
  • Structures can not have functions as members.
  • Class members are public by default.
  • None of these.
10. What would be the output of the following program? int main() { int x,y=10,z=10; x = (y = =z); cout<<
  • 1
  • 0
  • 10
  • Error