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

Cpp Programming

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

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

#include
class IndiaBix
{
int x, y, z;
public:
void Apply(int xx = 12, int yy = 21, int zz = 9)
{
x = xx;
y = yy += 10;
z = x -= 2;
}
void Display(void)
{
cout<< x << " " << y << endl; } void SetValue(int xx, int yy) { Apply(xx, 0, yy); } }; int main() { IndiaBix *pBix= new IndiaBix; (*pBix).SetValue(12, 20); pBix->Display();
delete pBix;
return 0;
}

[A].10 10
[B].12 10
[C].12 21
[D].12 31 

Answer: Option A

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

Cpp Programming, Functions

Cpp Programming Quiz 202 – What is correct about the following program?

Question: What is correct about the following program?

#include
class Base
{
int x, y, z;
public:
Base()
{
x = y = z = 0;
}
Base(int xx, int yy = 'A', int zz = 'B')
{
x = xx;
y = x + yy;
z = x + y;
}
void Display(void)
{
cout<< x << " " << y << " " << z << endl; } }; class Derived : public Base { int x, y; public: Derived(int xx = 65, int yy = 66) : Base(xx, yy) { y = xx; x = yy; } void Display(void) { cout<< x << " " << y << " "; Display(); } }; int main() { Derived objD; objD.Display(); return 0; }

[A].The program will report compilation error.
[B].The program will run successfully giving the output 66 65.
[C].The program will run successfully giving the output 65 66.
[D].The program will run successfully giving the output 66 65 65 131 196. 

Answer: Option C

Cpp Programming Quiz 202 – What is correct about the following program? Read More »

Cpp Programming, Functions

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

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

#include
class Base
{
public:
char S, A, M;
Base(char x, char y)
{
S = y - y;
A = x + x;
M = x * x;
}
Base(char, char y = 'A', char z = 'B')
{
S = y;
A = y + 1 - 1;
M = z - 1;
}
void Display(void)
{
cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { char x, y, z; public: Derived(char xx = 65, char yy = 66, char zz = 65): Base(x) { x = xx; y = yy; z = zz; } void Display(int n) { if(n) Base::Display(); else cout<< x << " " << y << " " << z << endl; } }; int main() { Derived objDev; objDev.Display(0-1); return 0; }

[A].A A A
[B].A B A
[C].A B C
[D].Garbage Garbage Garbage 

Answer: Option A

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

Cpp Programming, Functions

Cpp Programming Quiz 204 – 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
static int Result;
class India
{
public:
void Change(int x = 10, int y = 20, int z = 30)
{
cout<< x + y + z; } void Display(int x = 40, float y = 50.00) { Result = x % x; cout<< Result; } }; class Bix { int x, y; public: void Change(int x, int y = 50) { cout<< x + y; } }; class IndiaBix: public India, public Bix { public: void Display(int x = 10, int xx = 100, int xxx = 1000) { Result = x + xx % x * x; cout<< Result ; } }; int main() { IndiaBix objBix; objBix.India::Display(10, 20.00); return 0; }

[A].The program will print the output 0.
[B].The program will print the output 10.
[C].The program will print the output 30.
[D].The program will print the output 40. 

Answer: Option A

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

Cpp Programming, Functions

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

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

#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

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

Cpp Programming, Functions

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