ExamVeda
Login
Home
51
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 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
52
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 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
53
Which of the following constructors are provided by the C++ compiler if not defined in a class?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
54
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 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
55
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 a1, a2(10);
	cout<<a2.a;
	return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
56
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 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
57
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A{
	mutable int a;
public:
	A(){
		cout<<"A's Constructor called\n";
	}
	~A(){
		cout<<"A's Destructor called\n";
	}
};
 
class B{
	static A a;
public:
	B(){
		cout<<"B's Constructor called\n";
	}
	~B(){
		cout<<"B's Destructor called\n";
	}
};
 
A B::a;
 
int main(int argc, char const *argv[])
{
	return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
58
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 a1, a2(10);
	cout<<a2.a;
	return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
59
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A{
	mutable int a;
public:
	A(){
		cout<<"A's default constructor called\n";
	}
	A(const A& a){
		cout<<"A's copy Constructor called\n";
	}
};
class B{
	A obj;
public:
	B(){
		cout<<"B's Constructor called\n";
	}
};
int main(int argc, char const *argv[])
{
	B b1;
	B b2;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
60
Why constructors are efficient instead of a function init() defined by the user to initialize the data members of an object?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board