MCQGeeks
0 : 0 : 1
CBSE
JEE
NTSE
NEET
English
UK Quiz
Quiz
Driving Test
Practice
Games
Quiz
Cplusplus Interview
Cplusplus Programming Written Test
Quiz 1
1
2
3
4
5
6
7
8
9
10
11
Q.1
Which of the following constructors are provided by the C++ compiler if not defined in a class?
a) Default constructor
b) Assignment constructor
c) Copy constructor
d) All of the mentioned
Q.2
When a copy constructor is called?
a) When an object of the class is returned by value
b) When an object of the class is passed by value to a function
c) When an object is constructed based on another object of the same class
d) All of the mentioned
Q.3
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ A(){ cout<<"Constructor called"; } }; int main(int argc, char const *argv[]) { A a; return}
a) Constructor called
b) Nothing printed
c) Error
d) Segmentation fault
Q.4
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: A(){ cout<<"Constructor called"; } }; int main(int argc, char const *argv[]) { A *a; return}
a) Constructor called
b) Nothing printed
c) Error
d) Segmentation fault
Q.5
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; }; int main(int argc, char const *argv[]) { A a1 = {10}; A a2 = a cout<<a1.a<<a2.a; return}
a) 1010
b) 87368746
c) Error
d) Segmentation fault
Q.6
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(int a){ this->a = a; } }; int main(int argc, char const *argv[]) { A aa2(10); cout<<a2.a; return}
a) 10
b) Compile time error
c) Run-time error
d) No output
Q.7
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(int a=0){ this->a = a; } }; int main(int argc, char const *argv[]) { A aa2(10); cout<<a2.a; return}
a) 010
b) 100
c) 001
d) Error
Q.8
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(){ cout<<"Constructor called"; } }; int main(int argc, char const *argv[]) { A *a1 = (A*)malloc(sizeof(A)); return}
a) Constructor called
b) Nothing printed
c) Error
d) Segmentation fault
Q.9
What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: int a; A(){ cout<<"Constructor called"; } } a; int main(int argc, char const *argv[]) { return}
a) Constructor called
b) Nothing printed
c) Error
d) Segmentation fault
Q.10
How destructor overloading is done?
a) By changing the number of parameters
b) By changing the parameters type
c) By changing both the number of parameters and their type
d) No chance for destructor overloading
Q.11
Which of the following is correct?
a) Destructors can be virtual
b) There can be more than one destructor in a class
c) Destructor definition starts with !
d) Destructor is used to initialize objects
0 h : 0 m : 1 s
1
2
3
4
5
6
7
8
9
10
11
Report Question
×
What's an issue?
Question is wrong
Answer is wrong
Other Reason
Want to elaborate a bit more? (optional)
Support mcqgeeks.com by disabling your adblocker.
×
Please disable the adBlock and continue.
Thank you.
Reload page