61. Pick out the correct option.
62. What is the identifier given to string class to declare string objects?
63. Which is used to do the dereferencing?
64. Pick out the correct statement.
65. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
double arr[] = {5.0, 6.0, 7.0, 8.0};
double *p = (arr+2);
cout << *p << endl;
cout << arr << endl;
cout << *(arr+3) << endl;
cout << *(arr) << endl;
cout << *arr+9 << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
double arr[] = {5.0, 6.0, 7.0, 8.0};
double *p = (arr+2);
cout << *p << endl;
cout << arr << endl;
cout << *(arr+3) << endl;
cout << *(arr) << endl;
cout << *arr+9 << endl;
return 0;
}66. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class B
{
int b;
public:
B(){}
B(int i){
b = i;
}
int show(){
return b;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show(){
C c(10);
cout<<"value of b is: "<<c.b.show()<<endl;
}
};
int main(int argc, char const *argv[])
{
C c(1);
c.show();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class B
{
int b;
public:
B(){}
B(int i){
b = i;
}
int show(){
return b;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show(){
C c(10);
cout<<"value of b is: "<<c.b.show()<<endl;
}
};
int main(int argc, char const *argv[])
{
C c(1);
c.show();
return 0;
}67. Which is the correct way of concatenating a character at the end of a string object?
way 1:
string s;
s = s + 'a';
way 2:
string s;
s.push_back('a');
way 1:
string s;
s = s + 'a';
way 2:
string s;
s.push_back('a');68. 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 s1 = "Hello";
string s2 = "World";
string s3 = s1 + " " + s2;
cout<<s3;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
string s1 = "Hello";
string s2 = "World";
string s3 = s1 + " " + s2;
cout<<s3;
return 0;
}69. When we are using heap operations what do we need to do to save the memory?
70. Which method do we use to append more than one character at a time?
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.
