C++ MCQ’s

C++ MCQ’s Home Page

C++ Basic 1
C++ Basic 2
C++ Basic 3
C++ Basic 4
C++ Basic 5
C++ OOPs Concepts 1
C++ OOPs Concepts 2
C++ OOPs Concepts 3
C++ OOPs Concepts 4
C++ OOPs Concepts 5

 

C++ Language MCQ’S | OOPs Concepts Set 3

11.
Which of the following is the scope resolution operator?

a) .
b) *
c) ::
d) ~

 

12.
What will be the output of the following C++ code?

#include<iostream>
using namespace std;
int x = 1;
int main()
{
int x = 2;
{
int x = 3;
cout << ::x << endl;
}
return 0;
}

a) 1
b) 2
c) 3
d) 123

 

13.
What will be the output of the following C++ code?

#include<iostream>
using namespace std;
class A
{
~A(){
cout<<“Destructor called\n”;
}
};
int main()
{
A a;
return 0;
}

a) Destructor called
b) Nothing will be printed
c) Error
d) Segmentation fault

 

14.
What will be the output of the following C++ code?

#include<iostream>
using namespace std;
class A
{
~A(){
cout<<“Destructor called\n”;
}
};
int main()
{
A *a1 = new A();
A *a2 = new A();
return 0;
}

a) Destructor called
b)
Destructor called
Destructor called
c) Error
d) Nothing is printed

 

15.
What will be the output of the following C++ code?

#include<iostream>
using namespace std;
int x[100];
int main()
{
cout << x[99] << endl;
}

a) Garbage value
b) 0
c) 99
d) Error

 

Visitor Counter

0056679