Classes & Objects


  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


  1. Which special character is used to mark the end of class?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    ; special character is used to mark the end of class.



  1. What is the output of this program?
    #include 
    using namespace std;
    class num
    {
    int N;
    public:
    int getN();
    void putN(int M);
    };
    int num::getN()
    {
    return N;
    }
    void num::putN(int M)
    {
    N = M;
    }
    int main()
    {
    num obj;
    obj.putN(15);
    cout << obj.getN( );
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    We are getting the number and copying it to M and printing it.


  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base
    {
    protected:
    int K;
    public:
    Base(int num1)
    {
    K = num1;
    }
    ~Base()
    {
    }
    };
    class Derived: public Base
    {
    int L;
    public:
    Derived(int num1, int num2): Base(num2)
    {
    L = num1;
    }
    ~Derived()
    {
    }
    void show()
    {
    cout << K << " " << L << endl;
    }
    };
    int main()
    {
    Derived object(5, 6);
    object.show();
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are passing the values and assigning it to K and L and we are printing it.



  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.