Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. How many specifiers are used to derive a class?
Correct Answer is : dynamic memory allocation
2. Which specifier makes all the data members and functions of base class inaccessible by the derived class?
Correct Answer is : catch(…)
3. If a class is derived privately from a base class then ______________________________
Correct Answer is : Exception occurred: Thrown value is -1
4. What is the output of the following C++ code?
#include
#include
using namespace std;
class A
{
int a, b;
float d;
public:
void change(int i){
a = i;
}
void value_of_a(){
cout<
5. What is the output of the following C++ code?
#include
#include
using namespace std;
class A
{
float d;
public:
int a;
void change(int i){
a = i;
}
void value_of_a(){
cout<
6. What is the output of the following C++ code?
#include
#include
using namespace std;
class A
{
float d;
public:
A(){
cout<<"Constructor of class A\n";
}
};
class B: public A
{
int a = 15;
public:
B(){
cout<<"Constructor of class B\n";
}
};
int main(int argc, char const *argv[])
{
B b;
return 0;
}
Correct Answer is : exception occured: exiting
7. What is a virtual function in C++?
Correct Answer is : both caught int & unexpected called
8. Which is the correct syntax of declaring a virtual function?
Correct Answer is : terminate
9. What is the output of the following C++ code?
#include
#include
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;
a->func();
return 0;
}
Correct Answer is : unhandled
10. What is the output of the following C++ code?
#include
#include
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;
}
Correct Answer is :
11. Which statement is incorrect about virtual function.
Correct Answer is : ofstream
12. The concept of deciding which function to invoke during runtime is called ______________________
Correct Answer is : fstream
13. What is a pure virtual function?
Correct Answer is : ios::trunc
14. What is the output of the following C++ code?
#include
#include
using namespace std;
class Mammal
{
public:
Mammal(){
cout<<"I'm a Mammal\n";
}
~Mammal(){}
};
class Human: public Mammal
{
public:
Human(){
cout<<"I'm a Human\n";
}
~Human(){}
};
class Male: public Human
{
public:
Male(){
cout<<"I'm a Male\n";
}
~Male(){}
};
class Female: public Human
{
public:
Female(){
cout<<"I'm a Female\n";
}
~Female(){}
};
int main(int argc, char const *argv[])
{
Male M;
return 0;
}
Correct Answer is : 45294
15. What is the order of Constructors call when the object of derived class B is declared, provided class B is derived from class A?
Correct Answer is : Text
16. What is the order of Destructors call when the object of derived class B is declared, provided class B is derived from class A?
Correct Answer is : To truncate an existing file to zero
17. What is the output of the following C++ Code?
#include
#include
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;
}
Correct Answer is : ios::out
18. What is the output of the following C++ code?
#include
#include
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 = new Mammal();
Male m;
Female f;
*M = m;
M->Define();
M = &m;
M->Define();
return 0;
}
Correct Answer is : bool
19. Virtual functions in C++ tells the compiler to perform ______________________ on such functions.
Correct Answer is : ios::set
20. What is the output of the following C++ code?
#include
#include
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;
}