91. subscript operator is used to access which elements?
92. Which keyword is used to represent a friend function?
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;
}
#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;
}94. What is Character-Array?
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;
}
#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();
}
#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;
}
#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;
}99. What will be the output of the following C++ code?
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int a = 21;
int c ;
c = a++;
cout << c;
return 0;
}
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int a = 21;
int c ;
c = a++;
cout << c;
return 0;
}100. Which keyword is used to define the user defined data types?
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.
