Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

Constructors And Destructors

Cpp Programming Quiz 206 – Which of the following statement is correct about the program given below?

Question: Which of the following statement is correct about the program given below?

#include
class IndiaBix
{
int x, y;
public:
IndiaBix()
{
x = 0;
y = 0;
}
IndiaBix(int xx, int yy)
{
x = xx;
y = yy;
}
IndiaBix(IndiaBix *objB)
{
x = objB->x;
y = objB->y;
}
void Display()
{
cout<< x << " " << y; } }; int main() { IndiaBix objBix( new IndiaBix(20, 40) ); objBix.Display(); return 0; }

[A].The program will print the output 0 0 .
[B].The program will print the output 20 40 .
[C].The program will print the output Garbage Garbage .
[D].The program will report compile time error. 

Answer: Option B

Cpp Programming Quiz 206 – Which of the following statement is correct about the program given below? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 207 – Which of the following statement is correct about the program given below?

Question: Which of the following statement is correct about the program given below?

#include
class IndiaBix
{
int x;
public:
IndiaBix()
{
x = 0;
}
IndiaBix(int xx)
{
x = xx;
}
IndiaBix(IndiaBix &objB)
{
x = objB.x;
}
void Display()
{
cout<< x << " "; } }; int main() { IndiaBix objA(25); IndiaBix objB(objA); IndiaBix objC = objA; objA.Display(); objB.Display(); objC.Display(); return 0; }

[A].The program will print the output 25 25 25 .
[B].The program will print the output 25 Garbage 25 .
[C].The program will print the output Garbage 25 25 .
[D].The program will report compile time error. 

Answer: Option A

Cpp Programming Quiz 207 – Which of the following statement is correct about the program given below? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 208 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
int val = 0;
class IndiaBix
{
public:
IndiaBix()
{
cout<< ++val; } ~IndiaBix() { cout<< val--; } }; int main() { IndiaBix objBix1, objBix2, objBix3; { IndiaBix objBix4; } return 0; }

[A].1234
[B].4321
[C].12344321
[D].12341234 

Answer: Option C

Cpp Programming Quiz 208 – What will be the output of the following program? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 209 – What will be the output of the following program?

Question: What will be the output of the following program?

#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

Cpp Programming Quiz 209 – What will be the output of the following program? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 210 – What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?

Question: What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
[A].Compile-time error.
[B].Preprocessing error.
[C].Runtime error.
[D].Runtime exception.Answer: Option A

Cpp Programming Quiz 210 – What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 211 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class BixBase
{
public:
BixBase()
{
cout<< "Base OK. "; } virtual ~BixBase() { cout<< "Base DEL. "; } }; class BixDerived: public BixBase { public: BixDerived() { cout<< "Derived OK. "; } ~BixDerived() { cout<< "Derived DEL. "; } }; int main() { BixBase *basePtr = new BixDerived(); delete basePtr; return 0; }

[A].Base OK. Derived OK.
[B].Base OK. Derived OK. Base DEL.
[C].Base OK. Derived OK. Derived DEL.
[D].Base OK. Derived OK. Derived DEL. Base DEL.

Answer: Option D

Cpp Programming Quiz 211 – What will be the output of the following program? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 212 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class BixBase
{
public:
BixBase()
{
cout<< "Base OK. "; } ~BixBase() { cout<< "Base DEL. "; } }; class BixDerived: public BixBase { public: BixDerived() { cout<< "Derived OK. "; } ~BixDerived() { cout<< "Derived DEL. "; } }; int main() { BixBase *basePtr = new BixDerived(); delete basePtr; return 0; }

[A].Base OK. Derived OK.
[B].Base OK. Derived OK. Base DEL.
[C].Base OK. Derived OK. Derived DEL.
[D].Base OK. Derived OK. Derived DEL. Base DEL.

Answer: Option B

Cpp Programming Quiz 212 – What will be the output of the following program? Read More »

Constructors And Destructors, Cpp Programming

Cpp Programming Quiz 215 – If the copy constructor receives its arguments by value, the copy constructor would

Question: If the copy constructor receives its arguments by value, the copy constructor would
[A].call one-argument constructor of the class
[B].work without any problem
[C].call itself recursively[D].call zero-argument constructor

Answer: Option C

Cpp Programming Quiz 215 – If the copy constructor receives its arguments by value, the copy constructor would Read More »

Constructors And Destructors, Cpp Programming