ExamVeda
Login
Home
61
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a;
   public: 
	A(){
		a = 0;
	}
	void show(){
		a++;
		cout<<"a: "<<a<<endl;
	}
};
 
class B: private A
{
   public:
 
};
 
int main(int argc, char const *argv[])
{
	B b;
	b.show();
	return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
62
What is Inheritance in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
63
What is a virtual function in C++?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
64
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	float d;
    public:
	int a;
	void change(int i){
		a = i;
	}
	void value_of_a(){
		cout<<a;
	}
};
 
class B: public A
{
	int a = 15;
    public:
	void print(){
		cout<<a;
	}
};
 
int main(int argc, char const *argv[])
{
	B b;
	b.change(10);
	b.print();
	b.value_of_a();
 
	return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
65
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	float d;
   public:
	virtual void func(){
		cout<<"Hello this is class A\n";
	}
};
 
class B: public A
{
	int a = 15;
   public:
	void func(){
		cout<<"Hello this is class B\n";
	}
};
 
int main(int argc, char const *argv[])
{
	A *a = new A();
	B b;
	a = &b;
	a->func();
	return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
66
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Mammal
{
   public:
	virtual void Define(){
		cout<<"I'm a Mammal\n";
	}
};
 
class Human: public Mammal
{
   private:
	void Define(){
		cout<<"I'm a Human\n";
	}
};
 
int main(int argc, char const *argv[])
{
	Mammal *M = new Mammal();
	Human H;
	M = &H;
	M->Define();
	return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
67
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A{
	float d;
   public:
	virtual void func(){
		cout<<"Hello this is class A\n";
	}
};
 
class B: public A{
	int a = 15;
public:
	void func(){
		cout<<"Hello this is class B\n";
	}
};
 
int main(int argc, char const *argv[])
{
	B b;
	b.func();
	return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
68
Which concept of OOPs is shown by Virtual Functions?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
69
Virtual functions in C++ tells the compiler to perform . . . . . . . . on such functions.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
70
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Mammal
{
   public:
	virtual void Define(){
		cout<<"I'm a Mammal\n";
	}
};
 
class Human: public Mammal
{
   public:
	void Define(){
		cout<<"I'm a Human\n";
	}
};
 
class Male: public Human
{
   public:
	void Define(){
		cout<<"I'm a Male\n";
	}
};
 
class Female: public Human
{
   public:
	void Define(){
		cout<<"I'm a Female\n";
	}
};
 
int main(int argc, char const *argv[])
{
	Mammal *M;
	Male m;
	Female f;
	*M = m;
	M->Define();
	return 0;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board