93.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class sample
{
    private:
    int var;
    public:
    void input()
    {
       cout << var;
    }
    void output()
    {
       cout << "Variable entered is ";
       cout << var << "\n";
    }
};
int main()
{
    sample object;
    object.input();
    object.output();
    object.var();
    return 0;
}

95.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Box
{
	int capacity;
    public:
	Box(int cap){
		capacity = cap;
	}
 
	friend void show();
};
 
void show()
{	
	Box b(10);
	cout<<"Value of capacity is: "<<b.capacity<<endl;
}
 
int main(int argc, char const *argv[])
{
	show();
	return 0;
}

96.
Pick the incorrect statements out of the following.

97.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a;
 
   public:
	int assign(int i) const {
		a = i;
	}
	int return_value() const {
		return a;
	}
};
int main(int argc, char const *argv[])
{
	A obj;
	obj.assign(5);
	cout<<obj.return_value();
}

98.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
    string str ("Microsoft");
    for (size_t i = 0; i < str.length();)
    {
        cout << str.at(i-1);
    }
    return 0;
}

Read More Section(Classes and Objects in C plus plus)

Each Section contains maximum 100 MCQs question on Classes and Objects in C plus plus. To get more questions visit other sections.