

MCQOPTIONS
Saved Bookmarks
This section includes 226 Mcqs, each offering curated multiple-choice questions to sharpen your Engineering knowledge and support exam preparation. Choose a topic below to get started.
51. |
What is correct about the following program? #include<iostream.h> 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. |
E. | The program will produce the output 66 65 infinite number of times (or till stack memory overflow). |
Answer» D. The program will run successfully giving the output 66 65 65 131 196. | |
52. |
What will be the output of the following program? #include<iostream.h> 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» B. Garbage garbage 20 20 | |
53. |
Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { public: void Bix(int x = 15) { x = x/2; if(x > 0) Bix(); else cout<< x % 2; } }; int main() { IndiaBix objIB; objIB.Bix(); return 0; } |
A. | The program will display 1. |
B. | The program will display 2. |
C. | The program will display 15. |
D. | The program will go into an infinite loop. |
E. | The program will report error on compilation. |
Answer» E. The program will report error on compilation. | |
54. |
What will be the output of the following program? #include<iostream.h> class IndiabixSample { public: int a; float b; void BixFunction(int a, float b, float c = 100.0f) { cout<< a % 20 + c * --b; } }; int main() { IndiabixSample objBix; objBix.BixFunction(20, 2.000000f, 5.0f); return 0; } |
A. | 0 |
B. | 5 |
C. | 100 |
D. | -5 |
E. | None of these |
Answer» C. 100 | |
55. |
Which of the following statement is correct about the program given below? #include<iostream.h> class BixBase { int x, y; public: BixBase(int xx = 10, int yy = 10) { x = xx; y = yy; } void Show() { cout<< x * y << endl; } }; class BixDerived { private: BixBase objBase; public: BixDerived(int xx, int yy) : objBase(xx, yy) { objBase.Show(); } }; int main() { BixDerived objDev(10, 20); return 0; } |
A. | The program will print the output 100. |
B. | The program will print the output 200. |
C. | The program will print the output Garbage-value. |
D. | The program will report compile time error. |
Answer» C. The program will print the output Garbage-value. | |
56. |
Which of the following statement is correct about the program given below? #include<iostream.h> #include<process.h> class IndiaBix { static int x; public: IndiaBix() { if(x == 1) exit(0); else x++; } void Display() { cout<< x << " "; } }; int IndiaBix::x = 0; int main() { IndiaBix objBix1; objBix1.Display(); IndiaBix objBix2; objBix2.Display(); return 0; } |
A. | The program will print the output 1 2. |
B. | The program will print the output 0 1. |
C. | The program will print the output 1 1. |
D. | The program will print the output 1. |
E. | The program will report compile time error. |
Answer» E. The program will report compile time error. | |
57. |
What will be the output of the following program? #include<iostream.h> class Bix { int x, y; public: void show(void); void main(void); }; void Bix::show(void) { Bix b; b.x = 2; b.y = 4; cout<< x << " " << y; } void Bix::main(void) { Bix b; b.x = 6; b.y = 8; b.show(); } int main(int argc, char *argv[]) { Bix run; run.main(); return 0; } |
A. | 2 4 |
B. | 6 8 |
C. | The program will report error on Compilation. |
D. | The program will report error on Linking. |
E. | The program will report error on Run-time. |
Answer» C. The program will report error on Compilation. | |
58. |
What will be the output of the following program? #include<iostream.h> #include<string.h> 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» C. 5 | |
59. |
Which of the following constructor is used in the program given below? #include<iostream.h> class IndiaBix { int x, y; public: IndiaBix(int xx = 10, int yy = 20 ) { x = xx; y = yy; } void Display() { cout<< x << " " << y << endl; } ~IndiaBix() { } }; int main() { IndiaBix objBix; objBix.Display(); return 0; } |
A. | Copy constructor |
B. | Simple constructor |
C. | Non-parameterized constructor |
D. | Default constructor |
Answer» E. | |
60. |
What will be the output of the following program? #include<iostream.h> 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. |
E. | Base OK. Derived OK. Base DEL. Derived DEL. |
Answer» C. Base OK. Derived OK. Derived DEL. | |
61. |
Which of the following statement is correct about the program given below? #include<iostream.h> void Tester(float xx, float yy = 5.0); class IndiaBix { float x; float y; public: void Tester(float xx, float yy = 5.0) { x = xx; y = yy; cout<< ++x % --y; } }; int main() { IndiaBix objBix; objBix.Tester(5.0, 5.0); return 0; } |
A. | The program will print the output 0. |
B. | The program will print the output 1. |
C. | The program will print the output 2. |
D. | The program will print the output garbage value. |
E. | The program will report compile time error. |
Answer» F. | |
62. |
Which of the following statement is correct about the program given below? #include<iostream.h> const double BixConstant(const int, const int = 0); int main() { const int c = 2 ; cout<< BixConstant(c, 10)<< " "; cout<< BixConstant(c, 20)<< endl; return 0; } const double BixConstant(const int x, const int y) { return( (y + (y * x) * x % y) * 0.2); } |
A. | The program will print the output 2 4. |
B. | The program will print the output 20 40. |
C. | The program will print the output 10 20. |
D. | The program will print the output 20 4.50. |
E. | The program will report compile time error. |
Answer» B. The program will print the output 20 40. | |
63. |
What will be the output of the following program? #include<iostream.h> 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. |
E. | The program will report compile time error. |
Answer» E. The program will report compile time error. | |
64. |
What will be the output of the following program? #include<iostream.h> class AreaFinder { float l, b, h; float result; public: AreaFinder(float hh = 0, float ll = 0, float bb = 0) { l = ll; b = bb; h = hh; } void Display(int ll) { if(l = 0) result = 3.14f * h * h; else result = l * b; cout<< result; } }; int main() { AreaFinder objAF(10, 10, 20); objAF.Display(0); return 0; } |
A. | 0 |
B. | 314 |
C. | 314.0000 |
D. | 200.0000 |
Answer» B. 314 | |
65. |
What will be the output of the following program? #include<iostream.h> 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 |
E. | The program will report compile time error. |
Answer» D. Garbage Garbage | |
66. |
What will be the output of the following program? #include<iostream.h> class IndiaBix { int x, y; public: IndiaBix(int xx) { x = ++xx; } ~IndiaBix() { cout<< x - 1 << " "; } void Display() { cout<< --x + 1 << " "; } }; int main() { IndiaBix objBix(5); objBix.Display(); int *p = (int*) &objBix; *p = 40; objBix.Display(); return 0; } |
A. | 6 6 4 |
B. | 6 6 5 |
C. | 5 40 38 |
D. | 6 40 38 |
E. | 6 40 39 |
Answer» E. 6 40 39 | |
67. |
What will be the output of the following program? #include<iostream.h> 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. |
E. | Base OK. Derived OK. Base DEL. Derived DEL. |
Answer» E. Base OK. Derived OK. Base DEL. Derived DEL. | |
68. |
What will be the output of the following program? #include<iostream.h> class BixBase { public: int x, y; BixBase(int xx = 0, int yy = 5) { x = ++xx; y = --yy; } void Display() { cout<< --y; } ~BixBase(){} }; class BixDerived : public BixBase { public: void Increment() { y++; } void Display() { cout<< --y; } }; int main() { BixDerived objBix; objBix.Increment(); objBix.Display(); return 0; } |
A. | 3 |
B. | 4 |
C. | 5 |
D. | Garbage-value |
E. | The program will report compile time error. |
Answer» C. 5 | |
69. |
Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int *p; public: IndiaBix(int xx, char ch) { p = new int(); *p = xx + int(ch); cout<< *p; } ~IndiaBix() { delete p; } }; int main() { IndiaBix objBix(10, 'B'); return 0; } |
A. | The program will print the output 76. |
B. | The program will print the output 108. |
C. | The program will print the output garbage value. |
D. | The program will report compile time error. |
Answer» B. The program will print the output 108. | |
70. |
What will be the output of the following program? #include<iostream.h> 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. |
E. | The program will report compile time error. |
Answer» E. The program will report compile time error. | |
71. |
What is the technical word for the function ~IndiaBix() defined in the following program? #include<iostream.h> class IndiaBix { int x, y; public: IndiaBix(int xx = 10, int yy = 20 ) { x = xx; y = yy; } void Display() { cout<< x << " " << y << endl; } ~IndiaBix() { } }; int main() { IndiaBix objBix; objBix.Display(); return 0; } |
A. | Constructor |
B. | Destructor |
C. | Default Destructor |
D. | Function Template |
Answer» C. Default Destructor | |
72. |
What will be the output of the following program? #include<iostream.h> 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» B. Class B. | |
73. |
Which of the following statement is correct about the program given below? #include<iostream.h> class BixBase { int x, y; public: BixBase(int xx = 10, int yy = 10) { x = xx; y = yy; } void Show() { cout<< x * y << endl; } }; class BixDerived : public BixBase { private: BixBase objBase; public: BixDerived(int xx, int yy) : BixBase(xx, yy), objBase(yy, yy) { objBase.Show(); } }; int main() { BixDerived objDev(10, 20); return 0; } |
A. | The program will print the output 100. |
B. | The program will print the output 200. |
C. | The program will print the output 400. |
D. | The program will print the output Garbage-value. |
E. | The program will report compile time error. |
Answer» D. The program will print the output Garbage-value. | |
74. |
What will be the output of the following program? #include<iostream.h> class India { public: struct Bix { int x; float y; void Function(void) { y = x = (x = 4*4); y = --y * y; } void Display() { cout<< y << endl; } }B; }I; int main() { I.B.Display(); return 0; } |
A. | 0 |
B. | 1 |
C. | -1 |
D. | Garbage value |
Answer» B. 1 | |
75. |
What will be the output of the following program? #include<iostream.h> #include<string.h> 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» C. 24 | |
76. |
Which of the following statement is correct about the program given below? #include<iostream.h> #include<string.h> class IndiaBix { public: void GetData(char *s, int x, int y ) { int i = 0; for (i = x-1; y>0; i++) { cout<< s[i]; y--; } } }; int main() { IndiaBix objBix; objBix.GetData((char*)"Welcome!", 1, 3); return 0; } |
A. | The program will print the output me!. |
B. | The program will print the output Wel. |
C. | The program will print the output !em. |
D. | The program will print the output Welcome!. |
E. | The program will result in a compile time error. |
Answer» C. The program will print the output !em. | |
77. |
Which of the following statement is correct about the program given below? #include<iostream.h> 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» C. The program will print the output 4 5 6. | |
78. |
Which of the following statement is correct about the program given below? #include<iostream.h> 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» D. The program will report compile time error. | |
79. |
What will be the output of the following program? #include<iostream.h> 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 |
E. | The program will report compile time error. |
Answer» E. The program will report compile time error. | |
80. |
What will be the output of the following program? #include<iostream.h> 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» B. The program will print the ASCII value of 4. | |
81. |
Which of the following statement is correct about the program given below? #include<iostream.h> class BixBase { int x, y; public: BixBase(int xx = 10, int yy = 10) { x = xx; y = yy; } void Show() { cout<< x * y << endl; } }; class BixDerived : public BixBase { private: BixBase objBase; public: BixDerived(int xx, int yy) : BixBase(xx, yy) { objBase.Show(); } }; int main() { BixDerived objDev(10, 20); return 0; } |
A. | The program will print the output 100. |
B. | The program will print the output 200. |
C. | The program will print the output Garbage-value. |
D. | The program will report compile time error. |
Answer» B. The program will print the output 200. | |
82. |
What will be the output of the following program? #include<iostream.h> struct MyData { public: int Addition(int a, int b = 10) { return (a *= b + 2); } float Addition(int a, float b); }; int main() { MyData data; cout<<data.Addition(1)<<" "; cout<<data.Addition(3, 4); return 0; } |
A. | 12 12 |
B. | 12 18 |
C. | 3 14 |
D. | 18 12 |
E. | Compilation fails. |
Answer» C. 3 14 | |
83. |
Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { static int x; public: static void SetData(int xx) { x = xx; } static void Display() { cout<< x ; } }; int IndiaBix::x = 0; int main() { IndiaBix::SetData(44); IndiaBix::Display(); return 0; } |
A. | The program will print the output 0. |
B. | The program will print the output 44. |
C. | The program will print the output Garbage. |
D. | The program will report compile time error. |
Answer» C. The program will print the output Garbage. | |
84. |
What will be the output of the following program? #include<iostream.h> 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» B. 46 22 | |
85. |
Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { static int x; public: static void SetData(int xx) { this->x = xx; } static void Display() { cout<< x ; } }; int IndiaBix::x = 0; int main() { IndiaBix::SetData(22); IndiaBix::Display(); return 0; } |
A. | The program will print the output 0. |
B. | The program will print the output 22. |
C. | The program will print the output Garbage. |
D. | The program will report compile time error. |
Answer» E. | |
86. |
Which of the following statement is correct with respect to the use of friend keyword inside a class? |
A. | A private data member can be declared as a friend. |
B. | A class may be declared as a friend. |
C. | An object may be declared as a friend. |
D. | We can use friend keyword as a class name. |
Answer» C. An object may be declared as a friend. | |
87. |
Which of the following keywords is used to control access to a class member? |
A. | Default |
B. | Break |
C. | Protected |
D. | Asm |
Answer» D. Asm | |
88. |
Which of the following statement is correct about the program given below? #include<iostream.h> class Bix { int x; public: Bix(); void Show() const; ~Bix(){} }; Bix::Bix() { x = 5; } void Bix::Show() const { cout<< x; } int main() { Bix objB; objB.Show(); return 0; } |
A. | The program will print the output 5. |
B. | The program will print the output Garbage-value. |
C. | The program will report compile time error. |
D. | The program will report runtime error. |
Answer» B. The program will print the output Garbage-value. | |
89. |
What will be the output of the following program? #include<iostream.h> 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 |
E. | 43211234 |
Answer» D. 12341234 | |
90. |
Which of the following statement is correct regarding destructor of base class? |
A. | Destructor of base class should always be static. |
B. | Destructor of base class should always be virtual. |
C. | Destructor of base class should not be virtual. |
D. | Destructor of base class should always be private. |
Answer» C. Destructor of base class should not be virtual. | |
91. |
Which of the following two entities (reading from Left to Right) can be connected by the dot operator? |
A. | A class member and a class object. |
B. | A class object and a class. |
C. | A class and a member of that class. |
D. | A class object and a member of that class. |
Answer» E. | |
92. |
What happens when we try to compile the class definition in following code snippet? class Birds {}; class Peacock : protected Birds {}; |
A. | It will not compile because class body of Birds is not defined. |
B. | It will not compile because class body of Peacock is not defined. |
C. | It will not compile because a class cannot be protectedly inherited from other class. |
D. | It will compile succesfully. |
Answer» E. | |
93. |
How can we make a class abstract? |
A. | By making all member functions constant. |
B. | By making at least one member function as pure virtual function. |
C. | By declaring it abstract using the static keyword. |
D. | By declaring it abstract using the virtual keyword. |
Answer» C. By declaring it abstract using the static keyword. | |
94. |
Which of the following function prototype is perfectly acceptable? |
A. | <i class="cpp-code">int Function(int Tmp = Show());</i> |
B. | <i class="cpp-code">float Function(int Tmp = Show(int, float));</i> |
C. | Both A and B. |
D. | <i class="cpp-code">float = Show(int, float) Function(Tmp);</i> |
Answer» B. <i class="cpp-code">float Function(int Tmp = Show(int, float));</i> | |
95. |
Which of the following statement is correct about the program given below? #include<iostream.h> int x, y; class BixTest { public: BixTest(int xx = 0, int yy = 0) { x = xx; y = yy; Display(); } void Display() { cout<< x << " " << y << " "; } }; int main() { BixTest objBT(10, 20); int &rx = x; int &ry = y; ry = x; rx = y; cout<< rx--; return 0; } |
A. | The program will print the output 0 0 10. |
B. | The program will print the output 10 20 10. |
C. | The program will print the output 10 20 9. |
D. | It will result in a compile time error. |
Answer» C. The program will print the output 10 20 9. | |
96. |
Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int a, b, c; public: void SetValue(int x, int y ,int z) { a = x; b = y; c = z; } void Display() { cout<< a << " " << b << " " << c; } }; int main() { IndiaBix objBix; int x = 2; int &y = x; y = 5; objBix.SetValue(x, ++y, x + y); objBix.Display(); return 0; } |
A. | The program will print the output 5 6 10. |
B. | The program will print the output 6 6 10. |
C. | The program will print the output 6 6 12. |
D. | It will result in a compile time error. |
Answer» C. The program will print the output 6 6 12. | |
97. |
Which of the following statement is correct about the program given below? #include<iostream.h> int i, j; class IndiaBix { public: IndiaBix(int x = 0, int y = 0) { i = x; j = x; Display(); } void Display() { cout<< j <<" "; } }; int main() { IndiaBix objBix(10, 20); int &s = i; int &z = j; i++; cout<< s-- << " " << ++z; return 0; } |
A. | The program will print the output 0 11 21. |
B. | The program will print the output 10 11 11. |
C. | The program will print the output 10 11 21. |
D. | The program will print the output 10 11 12. |
E. | It will result in a compile time error. |
Answer» C. The program will print the output 10 11 21. | |
98. |
What will be the output of the program given below? #include<iostream.h> class BixBase { int x; public: BixBase(int xx = 0) { x = xx; } void Display() { cout<< x ; } }; class BixDerived : public BixBase { int y; public: BixDerived(int yy = 0) { y = yy; } void Display() { cout<< y ; } }; int main() { BixBase objBase(10); BixBase &objRef = objBase; BixDerived objDev(20); objRef = objDev; objDev.Display(); return 0; } |
A. | 0 |
B. | 10 |
C. | 20 |
D. | Garbage-value |
E. | It will result in a compile-time/run-time error. |
Answer» D. Garbage-value | |
99. |
Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x, y; public: IndiaBix(int xx = 0, int yy = 0) { x = xx; y = yy; } void Display() { cout<< x << " " << y; } IndiaBix operator +(IndiaBix z) { IndiaBix objTemp; objTemp.x = x + z.x; objTemp.y = y + z.y; return objTemp; } }; int main() { IndiaBix objBix1(90, 80); IndiaBix objBix2(10, 20); IndiaBix objSum; IndiaBix &objRef = objSum; objRef = objBix1 + objBix2; objRef.Display(); return 0; } |
A. | It will result in a runtime error. |
B. | It will result in a compile time error. |
C. | The program will print the output 9 4. |
D. | The program will print the output 100 100. |
Answer» E. | |
100. |
Which of the following statement is correct about the program given below? #include<iostream.h> class Bix { int x, y; public: Bix(int x, int y) { this->x = x; this->y = y; } void Display() { cout<< x << " " << y; } }; int main() { int x = 50; int &y = x ; Bix b(y, x); return 0; } |
A. | The program will print the output 50 50. |
B. | The program will print the two garbage values. |
C. | It will result in a compile time error. |
D. | The program will print nothing. |
Answer» E. | |