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

Objects And Classes

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

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

#include
class Point
{
int x, y;
public:
Point(int xx = 10, int yy = 20)
{
x = xx;
y = yy;
}
Point operator + (Point objPoint)
{
Point objTmp;
objTmp.x = objPoint.x + this->x;
objTmp.y = objPoint.y + this->y;
return objTmp;
}
void Display(void)
{
cout<< x << " " << y; } }; int main() { Point objP1; Point objP2(1, 2); Point objP3 = objP1 + objP2; objP3.Display(); return 0; }

[A]. 1 2
[B]. 10 20

[C]. 11 22
[D]. Garbage Garbage

Answer: Option C

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

Cpp Programming, Objects And Classes

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

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

#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

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

Cpp Programming, Objects And Classes

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

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

#include
class IndiaBix
{
static int count;
public:
static void First(void)
{
count = 10;
}
static void Second(int x)
{
count = count + x;
}
static void Display(void)
{
cout<< count << endl; } }; int IndiaBix::count = 0; int main() { IndiaBix :: First(); IndiaBix :: Second(5); IndiaBix :: Display(); return 0; }

[A].0
[B].5
[C].10
[D].15 

Answer: Option D

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

Cpp Programming, Objects And Classes

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

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

#include
#include
class IndiaBix
{
int val;
public:
void SetValue(char *str1, char *str2)
{
val = strcspn(str1, str2);
}
void ShowValue()
{
cout<< val; } }; int main() { IndiaBix objBix; objBix.SetValue((char*)"India", (char*)"Bix"); objBix.ShowValue(); return 0; }

[A].2
[B].3
[C].5
[D].8

Answer: Option B

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

Cpp Programming, Objects And Classes

Cpp Programming Quiz 104 – 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;
float y;
public:
void Function()
{
x = 4;
y = 2.50; delete this;
}
void Display()
{
cout<< x << " " << y; } }; int main() { IndiaBix *pBix = new IndiaBix(); pBix->Function();
pBix->Function();
pBix->Display();
return 0;
}

[A].The program will print the output 4 2.5.
[B].The program will print the output 4.
[C].The program will report runtime error.
[D].The program will report compile time error. 

Answer: Option C

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

Cpp Programming, Objects And Classes

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

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

#include
#include
class IndiaBix
{
char str[50];
char tmp[50];
public:
IndiaBix(char *s)
{
strcpy(str, s);
}
int BixFunction()
{
int i = 0, j = 0;
while(*(str + i))
{
if(*(str + i++) == ' ')
*(tmp + j++) = *(str + i);
}
*(tmp + j) = 0;
return strlen(tmp);
}
};
int main()
{
char txt[] = "Welcome to IndiaBix.com!";
IndiaBix objBix(txt);
cout<< objBix.BixFunction(); return 0; }

[A].1
[B].2
[C].24
[D].25 

Answer: Option B

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

Cpp Programming, Objects And Classes

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

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

#include
class Bix
{
public:
int x;
};
int main()
{
Bix *p = new Bix();

(*p).x = 10;
cout<< (*p).x << " " << p->x << " " ; p->x = 20;
cout<< (*p).x << " " << p->x ;

return 0;
}

[A].10 10 20 20
[B].Garbage garbage 20 20
[C].10 10 Garbage garbage
[D].Garbage garbage Garbage garbage

Answer: Option A

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

Cpp Programming, Objects And Classes

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

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

#include
class BixBase
{
public:
float x;
};
class BixDerived : public BixBase
{
public:
char ch;
void Process()
{
ch = (int)((x=12.0)/3.0);
}
void Display()
{
cout<< (int)ch; } }; int main() { class BixDerived *objDev = new BixDerived; objDev->Process();
objDev->Display();
return 0;
}

[A].The program will print the output 4.
[B].The program will print the ASCII value of 4.
[C].The program will print the output 0.
[D].The program will print the output garbage. 

Answer: Option A

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

Cpp Programming, Objects And Classes

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

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

#include
class BixTeam
{
int x, y;
public:
BixTeam(int xx)
{
x = ++xx;
}
void Display()
{
cout<< --x << " "; } }; int main() { BixTeam objBT(45); objBT.Display(); int *p = (int*)&objBT; *p = 23; objBT.Display(); return 0; }

[A].45 22
[B].46 22
[C].45 23
[D].46 23

Answer: Option A

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

Cpp Programming, Objects And Classes

Cpp Programming Quiz 109 – 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 BixData
{
int x, y, z;
public:
BixData(int xx, int yy, int zz)
{
x = ++xx;
y = ++yy;
z = ++zz;
}
void Show()
{
cout<< "" << x++ << " " << y++ << " " << z++; } }; int main() { BixData objData(1, 2, 3); objData.Show(); return 0; }

[A].The program will print the output 1 2 3.
[B].The program will print the output 2 3 4 .
[C].The program will print the output 4 5 6.
[D].The program will report compile time error.

Answer: Option B

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

Cpp Programming, Objects And Classes