Classes & Objects


  1. Pick out the correct statement.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Destructors are automatically invoked when a object goes out of scope or when a dynamically allocated object is deleted. Inheritance does not change this behavior. This is the reason a derived destructor cannot invoke its base class destructor.


  1. Where is the derived class is derived from?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Because derived inherits functions and variables from base.



  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Example
    {
    public:
    Example()
    {
    cout << "N::N()" << endl;
    }
    Example( Example const & )
    {
    cout << "N::N( N const & )" << endl;
    }
    Example& operator=( Example const & )
    {
    cout << "N::operator=(N const &)" << endl;
    }
    };
    Example function()
    {
    Example temp;
    return temp;
    }
    int main()
    {
    Example p = function();
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    As we are passing the object without any attributes it will return as N::N().


  1. Which container in c++ will take large objects?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Because the vector is mainly used to store large objects for the game
    programming and other operations etc.



  1. How to store the large objects in c++ if it extends its allocated memory?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    memory heap