Cpp Quiz interview questions

118 questions. Tap “Show answer” to check yourself.

Advertisement
  1. Keyword typed is used to declare

    1. A synonym for an existing type
    2. Absence of a type
    3. Objects that can be modified outside of a program control
    4. A member function that is defined in a subclass
    Show answer

    A. A synonym for an existing type

  2. In C++ programming language, to write data that contains variables of type flat to an object of type of stream, which of the following should be used?

    1. Put ( )
    2. Seekg ( )
    3. Write ( )
    4. Insertion operator
    Show answer

    C. Write ( )

  3. Classes are useful because they

    1. Can closely model objects in the real world
    2. Bring together all aspects of an entity in one place
    3. Permit data to be hidden from other classes
    4. Are removed from memory when not in use
    Show answer

    C. Permit data to be hidden from other classes

  4. A function argument is a

    1. Value sent to function by the calling program
    2. Value returned by the function to the calling program
    3. Variable in the function that receives a value from the calling program
    4. Way that functions resist accepting the calling program’s values
    Show answer

    A. Value sent to function by the calling program

  5. The break statement causes an exit

    1. From the innermost loop or switch
    2. Only from the innermost switch
    3. Only from the innermost loop
    4. From all loops and switches
    Show answer

    D. From all loops and switches

  6. Element double array [7] is which element of the array?

    1. Sixth
    2. Seventh
    3. Eighth
    4. Impossible
    Show answer

    C. Eighth

  7. In C++, a structure brings together a group of

    1. Items of the same data type
    2. Integers with user-defined names
    3. Related data items, variables
    4. All of these
    Show answer

    C. Related data items, variables

  8. In C++, which of the following can legitimately be passed to a function?

    1. A constant
    2. A variable
    3. A structure
    4. All of these
    Show answer

    D. All of these

  9. The public files in a class library usually contain

    1. Variable definition
    2. Class declarations
    3. Constant definitions
    4. Member function definitions
    Show answer

    B. Class declarations

  10. The member function can always access the data in

    1. Any object of the class of which it is a member
    2. The public part of its class
    3. The class of which it is member
    4. The object of which is a member
    Show answer

    D. The object of which is a member

  11. In a stock, the data item placed on the stack first is

    1. Given as index zero
    2. Not given as index number
    3. The first data item to be removed
    4. The last data item to be removed
    Show answer

    D. The last data item to be removed

  12. Breaking a program into several files is desirable because

    1. A program can be divided functionally
    2. Each programmer can work on a separate file
    3. Some files don’t need to be recompiled each time
    4. Files can be marketed in object form
    Show answer

    A. A program can be divided functionally

  13. Advertisement
  14. Turbo C++ library function can be used

    1. Draw lines and circles
    2. Write text in a variety of fonts and sizes
    3. Color any closed figure
    4. All of these
    Show answer

    D. All of these

  15. Which of the following are good reasons to use an object oriented language?

    1. An object oriented program can be taught to correct its own errors
    2. Program statements are simpler than in procedural language
    3. We can define our own data types
    4. None of these
    Show answer

    C. We can define our own data types

  16. In a class specified, data or functions and designated private are accessible

    1. Only to public members of class
    2. Only if you know the password
    3. To any function in the program
    4. To member functions of that class
    Show answer

    D. To member functions of that class

  17. When a language has the capability to produce new data types, it is called

    1. Extensible
    2. Encapsulated
    3. Reprehensible
    4. None of these
    Show answer

    D. None of these

  18. The dot operator connects which of the following two entities?

    1. Class object and member of that class
    2. Class and member of that class
    3. Class object and a class
    4. Class member and class object
    Show answer

    A. Class object and member of that class

  19. A static function

    1. Should be called when an object is destroyed
    2. Can be called using the class name and function
    3. Is closely connected with an individual object of a class
    4. Is used when a dummy object must be created
    Show answer

    B. Can be called using the class name and function

  20. The function bad( ) is declared in the header file

    1. <iostream.h>
    2. <stdio.h>
    3. <math.h>
    4. <stdlib.h>
    Show answer

    C. <math.h>

  21. In C++, a function contained within a class is called

    1. A method
    2. A class function
    3. Member function
    4. None of these
    Show answer

    C. Member function

  22. A base class

    1. behave badly when chips are down
    2. will be a generalized version of its derived classes
    3. correspond to something in the real world
    4. offer model more specific objects than its derived classes
    Show answer

    B. will be a generalized version of its derived classes

  23. Copy constructor is invoked when a/an

    1. Argument is passed by value
    2. Argument is passed by reference
    3. Function returns for reference
    4. Function returns by value
    Show answer

    D. Function returns by value

  24. A project file

    1. contains instructions for compiling and linking
    2. contains definitions for C++ variables
    3. examines contents of the files in the project
    4. examines contents of the files in the project
    Show answer

    A. contains instructions for compiling and linking

  25. In C++, programs, the keyword friend appears in the

    1. class allowing access to another class
    2. private section of a class
    3. public section of a class
    4. all of these
    Show answer

    D. all of these

  26. Advertisement
  27. A C++ stream is

    1. Associated with a particular class
    2. Flow of control through a function
    3. A file
    4. A flow of data from one place to another
    Show answer

    D. A flow of data from one place to another

  28. The keyword volatile is used to declare

    1. Objects that can be modified outside of a program control
    2. Absence of a type
    3. A member function that is defined in a subclass
    4. All of these
    Show answer

    A. Objects that can be modified outside of a program control

  29. In C language, the break statement causes an exit

    1. Only from the innermost switch
    2. Only from the innermost loop
    3. From all loops and switches
    4. From the innermost loop or switch
    Show answer

    D. From the innermost loop or switch

  30. In a for loop with a multi-statement, loop body semicolons should appear

    1. The test expression
    2. Each statement within the loop body
    3. The closing brace in a multi-statement loop body
    4. Both (a) and (b)
    Show answer

    D. Both (a) and (b)

  31. In C++, when an argument is passed by reference

    1. A variable is created in the function to hold the argument’s value
    2. A temporary variable is created in the calling program to hold the argument’s value
    3. The function cannot access the argument’s value
    4. The function accesses the argument’s original value in the calling program
    Show answer

    A. A variable is created in the function to hold the argument’s value

  32. In new operator

    1. Each link contains data or a pointer to data
    2. Each link contains a pointer to the next link
    3. Links are stored in an array
    4. An array of pointers point to the links
    Show answer

    B. Each link contains a pointer to the next link

Advertisement