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

C++ Programming :: Constructors and Destructors

  1. Destructor calls are made in which order of the corresponding constructor calls?

  2. A.
    Reverse order
    B.
    Forward order
    C.
    Depends on how the object is constructed
    D.
    Depends on how many objects are constructed

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following never requires any arguments?

  4. A.
    Member function
    B.
    Friend function
    C.
    Default constructor
    D.
    const function

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. A class's __________ is called when an object is destroyed.

  6. A.
    constructor
    B.
    destructor
    C.
    assignment function
    D.
    copy constructor

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.

  8. A.
    are called
    B.
    are inherited
    C.
    are not called
    D.
    are created

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following statement is correct?

  10. A.
    A constructor of a derived class can access any public and protected member of the base class.
    B.
    Constructor cannot be inherited but the derived class can call them.
    C.
    A constructor of a derived class cannot access any public and protected member of the base class.
    D.
    Both A and B.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following statements are correct?

  12. A.
    Constructor is always called explicitly.
    B.
    Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
    C.
    Destructor is always called explicitly.
    D.
    Constructor and destructor functions are not called at all as they are always inline.

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. How many times a constructor is called in the life-time of an object?

  14. A.
    Only once
    B.
    Twice
    C.
    Thrice
    D.
    Depends on the way of creation of object

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following gets called when an object is being created?

  16. A.
    constructor
    B.
    virtual function
    C.
    destructor
    D.
    main

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .

  18. A.
    destructor
    B.
    delete
    C.
    delete[]
    D.
    kill[]
    E.
    free[]

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following statement is correct about constructors?

  20. A.
    A constructor has a return type.
    B.
    A constructor cannot contain a function call.
    C.
    A constructor has no return type.
    D.
    A constructor has a void return type.

    View Answer

    Workspace

    Discuss Discuss in Forum