C ++ Final Online Exam

50 Questions | Total Attempts: 104

SettingsSettingsSettings
Please wait...
C Plus Plus Quizzes & Trivia

With every final exam there is no doubt that some people will be unsure about their readiness to sit for it and getting some accurate quizzes to help you can give you the grade you want. Take up the C++ final online exam below and see how you would have scored.


Questions and Answers
  • 1. 
    What function initalizes variables in a class:
    • A. 

      CONSTRUCTOR

    • B. 

       Destructor

    • C. 

       Constitutor

    • D. 

       A and B are

  • 2. 
    To include code from the library in the program, such as iostream, a directive would be called up using this command.
    • A. 

       #include ; with iostream.h inside the brackets

    • B. 

       include (iostreamh)

    • C. 

       #include with iostream.h inside the brackets

    • D. 

       include #iostream,h;

  • 3. 
    Single line comments explaining code would be preceded like in the following example
    • A. 

       /**

    • B. 

       //

    • C. 

       *//

    • D. 

       /*

  • 4. 
    Which line has all reserved words ?
    • A. 

      Char, int, float, doubled, short, long, unsigned, signed

    • B. 

       sizeof, const, typedef, static, voided, enum, struct, union

    • C. 

      If, else, for, while do, switch, continue, break

    • D. 

      Defaulted, goto, return, extern, private, public, protected

  • 5. 
    What punctuation must each command line have at the end of the line ?
    • A. 

       :

    • B. 

       ,

    • C. 

       !

    • D. 

       ;

  • 6. 
    The C++ language is
    • A. 

       case-sensitive.

    • B. 

      Not case-sensitive.

    • C. 

      It depends

    • D. 

      None of these

  • 7. 
    The number 5.9875e17 must be stored in a(n):
    • A. 

       int

    • B. 

      Long

    • C. 

      Double

    • D. 

      Float

  • 8. 
    Select the correct definition for a string variable.
    • A. 

      String mystr;

    • B. 

      String mystr[20];

    • C. 

      String[20] mystr;

    • D. 

      Char mystr[20];

  • 9. 
    The sentence "Hello world!" uses _____ elements in a character array.
    • A. 

       10

    • B. 

       11

    • C. 

      12

    • D. 

      13

  • 10. 
    When you are creating a structure, you need to use the following keyword
    • A. 

      Structure

    • B. 

       struct

    • C. 

       object

    • D. 

       record

  • 11. 
    Select the correct function definition (NOT prototype) from the list below.
    • A. 

      Void intro();

    • B. 

      Double sin(double rad);

    • C. 

      Int foo(int bar; double baz)

    • D. 

      Double pow(double num, int pow);

  • 12. 
    Cout can print multiple values or variables in a single command using the following syntax:
    • A. 

       cout

    • B. 

       cout

    • C. 

       cout

    • D. 

       cout

  • 13. 
    Write a for loop that counts from 0 to 5.
    • A. 

      For (c = 0; c

    • B. 

      For (int c = 0; c

    • C. 

      For (c = 0; c < 5; c++)

    • D. 

      For (c = 0; c < 5; c++);

  • 14. 
    What does the statement #include do ?
    • A. 

      It defines the function iostream.h

    • B. 

       It defines the words TRUE and FALSE

  • 15. 
    Which of the following converts an integer "value" to its ASCII equivalent ?
    • A. 

       atoi(value)

    • B. 

       cout

    • C. 

      (char) value

    • D. 

      Char (value)

  • 16. 
    Which one of the choices would produce the following output ?
    • A. 

      Cout

    • B. 

      Cout

    • C. 

      Cout

    • D. 

       cin >> "Hello World";

  • 17. 
    What is the output of the following code? for (int i=0; i<10; i++); cout << i%2 << " "; }
    • A. 

      0 1 2 3 4 5 6 7 8 9

    • B. 

      0 2 4 6 8 10 12 14 16 18

    • C. 

      1 0 1 0 1 0 1 0 1 0

    • D. 

      0 1 0 1 0 1 0 1 0 1

  • 18. 
    What is the output of the following code? for (int a = 1; a <= 1; a++) cout << a++; cout << a;
    • A. 

       22

    • B. 

      12

    • C. 

      Error

    • D. 

      23

  • 19. 
    For which values of the integer _value will the following code become an infinite loop? int number=1; while (true) { cout << number; if (number == 3) break; number += _value; }
    • A. 

       only 0

    • B. 

      Only 1

    • C. 

       only 2

    • D. 

      Only 1 or 2

  • 20. 
    Inline functions are invoked at the time of
    • A. 

      Run time

    • B. 

      Compile time

    • C. 

      Depends on how it is invoked

    • D. 

      Both b and c above

  • 21. 
    Every class has at least one constructor function, even when none is declared.
    • A. 

      TRUE

    • B. 

      FALSE

  • 22. 
     How do we define a destructor?
    • A. 

      X~() {}

    • B. 

      X() {}~

    • C. 

      X() ~{}

    • D. 

      ~X() {}

  • 23. 
     Can constructors be overloaded?
    • A. 

      No

    • B. 

      Yes

  • 24. 
    Which of the following below can perform conversions between pointers to related classes?
    • A. 

      Cast_static

    • B. 

      Dynamic_cast

    • C. 

      Static_cast

    • D. 

      Cast_dynamic

  • 25. 
    An abstract class can be instantiated.
    • A. 

      TRUE

    • B. 

      FALSE

Back to Top Back to top