Home / C++ Programming / Constructors and Destructors :: General Questions

C++ Programming :: Constructors and Destructors

  1. If the copy constructor receives its arguments by value, the copy constructor would

  2. A.
    call one-argument constructor of the class
    B.
    work without any problem
    C.
    call itself recursively
    D.
    call zero-argument constructor

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following are NOT provided by the compiler by default?

  4. A.
    Zero-argument Constructor
    B.
    Destructor
    C.
    Copy Constructor
    D.
    Copy Destructor

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. It is a __________ error to pass arguments to a destructor.

  6. A.
    logical
    B.
    virtual
    C.
    syntax
    D.
    linker

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?

  8. A.
    Preprocessor
    B.
    Compiler
    C.
    Linker
    D.
    main() function

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

  10. A.
    default constructor
    B.
    copy constructor
    C.
    Both A and B
    D.
    None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. How many default constructors per class are possible?

  12. A.
    Only one
    B.
    Two
    C.
    Three
    D.
    Unlimited

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of the following statement is correct about destructors?

  14. A.
    A destructor has void return type.
    B.
    A destructor has integer return type.
    C.
    A destructor has no return type.
    D.
    A destructors return type is always same as that of main().

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following statement is correct?

  16. A.
    A constructor has the same name as the class in which it is present.
    B.
    A constructor has a different name than the class in which it is present.
    C.
    A constructor always returns an integer.
    D.
    A constructor cannot be overloaded.

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?

  18. A.
    Preprocessor
    B.
    Linker
    C.
    Loader
    D.
    Compiler

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. A destructor takes __________ arguments.

  20. A.
    one
    B.
    two
    C.
    three
    D.
    no

    View Answer

    Workspace

    Discuss Discuss in Forum