31. What does a class in C++ holds?
32. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
string str;
cin>>str;
cout<<str;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
string str;
cin>>str;
cout<<str;
return 0;
}
33. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
mutable 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
{
mutable 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();
}
34. What is the size of the heap?
35. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("helloworld.");
cout << str.substr(3).substr(4) << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("helloworld.");
cout << str.substr(3).substr(4) << endl;
return 0;
}
36. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
char str[] = "Hello World";
cout<<str[0];
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
char str[] = "Hello World";
cout<<str[0];
return 0;
}
37. Pick the correct statement about string objects in C++.
38. Why we use the "dynamic_cast" type conversion?
39. Which is used to return the number of characters in the string?
40. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int a = 0;
int b = 10;
if ( a && b )
{
cout << "true"<< endl ;
}
else
{
cout << "false"<< endl ;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a = 0;
int b = 10;
if ( a && b )
{
cout << "true"<< endl ;
}
else
{
cout << "false"<< endl ;
}
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.