Cpp Programming Quiz 264 – Which of the following gets called when an object is being created?
[A].
constructor
[B].
virtual function
[C].
destructor
[D].
main
Answer: Option A
Explanation:
No answer description available for this question.
virtual function
[C].
destructor
[D].
main
Answer: Option A
Explanation:
No answer description available for this question.
#include
class A
{
public:
void BixFunction(void)
{
cout<< "Class A" << endl;
}
};
class B: public A
{
public:
void BixFunction(void)
{
cout<< "Class B" << endl;
}
};
class C : public B
{
public:
void BixFunction(void)
{
cout<< "Class C" << endl;
}
};
int main()
{
A *ptr;
B objB;
ptr = &objB;
ptr = new C();
ptr->BixFunction();
return 0;
}
[A].Class A.
[B].Class B.
[C].Class C.
[D].The program will report compile time error.
Answer: Option A
#include
class IndiaBix
{
int K;
public:
void BixFunction(float, int , char);
void BixFunction(float, char, char);
};
int main()
{
IndiaBix objIB;
objIB.BixFunction(15.09, 'A', char('A' + 'A'));
return 0;
}
void IndiaBix::BixFunction(float, char y, char z)
{
K = int(z);
K = int(y);
K = y + z;
cout<< "K = " << K << endl;
}
[A]. The program will print the output M = 130.
[B]. The program will print the output M = 195.
[C]. The program will print the output M = -21.
[D]. The program will print the output M = -61.
Answer: Option D
#include
enum bix
{
a=1, b, c
};
int main()
{
int x = c;
int &y = x;
int &z = x;
y = b;
cout<< z--;
return 0;
}
[A].It will result in a compile time error.
[B].The program will print the output 1.
[C].The program will print the output 2.
[D].The program will print the output 3.
Answer: Option C
Answer: Option D
Answer: Option D