Cpp Programming Quiz 250 – A class’s __________ is called when an object is destroyed.
[A].
constructor
[B].
destructor
[C].
assignment function
[D].
copy constructor
Answer: Option B
Explanation:
No answer description available for this question.
destructor
[C].
assignment function
[D].
copy constructor
Answer: Option B
Explanation:
No answer description available for this question.
syntax
[D].
linker
Answer: Option C
Explanation:
No answer description available for this question.
#include
class BixBase
{
public:
BixBase()
{
cout<< "Base OK. ";
}
};
class BixDerived: public BixBase
{
public:
BixDerived()
{
cout<< "Derived OK. ";
}
~BixDerived()
{
cout<< "Derived DEL. ";
}
};
int main()
{
BixBase objB;
BixDerived objD;
objD.~BixDerived();
return 0;
}
[A].Base OK. Derived OK. Derived DEL.
[B].Base OK. Base OK. Derived OK. Derived DEL.
[C].Base OK. Derived OK. Derived DEL. Derived DEL.
[D].Base OK. Base OK. Derived OK. Derived DEL. Derived DEL.
Answer: Option D
[B].
Answer: Option B
Explanation:
No, Mentioning the array name in C or C++ gives the base address in all contexts except one.
Syntactically, the compiler treats the array name as a pointer to the first element. You can reference elements using array syntax, a[n], or using pointer syntax, *(a+n), and you can even mix the usages within an expression.
When you pass an array name as a function argument, you are passing the “value of the pointer”, which means that you are implicitly passing the array by reference, even though all parameters in functions are “call by value”.
Answer: Option C
#include
#include
class IndiaBix
{
char txtMsg[50];
public:
IndiaBix(char *str = NULL)
{
if(str != NULL)
strcpy(txtMsg, str);
}
int BixFunction(char ch);
};
int IndiaBix::BixFunction(char ch)
{
static int i = 0;
if(txtMsg[i++] == ch)
return strlen((txtMsg + i)) - i;
else
return BixFunction(ch);
}
int main()
{
IndiaBix objBix("Welcome to IndiaBix.com!");
cout<< objBix.BixFunction('t');
return 0;
}
[A].6
[B].8
[C].9
[D].15
Answer: Option A
[A].Only 1 is correct.
[B].Only 2 is correct.[C].Both 1 and 2 are correct.
[D].Both 1 and 2 are incorrect.
Answer: Option C