cpp-programming-objects-and-classes Related Question Answers

26. 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; }





27. 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; }






28. 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; }





29. 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; }





30. 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; }






31. 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; }





32. 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; }






33. 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; }





34. 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; }





35. 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; }






36. 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; }





37. What happens when we try to compile the class definition in following code snippet? class Birds {}; class Peacock : protected Birds {};





38. Which of the following statement is correct regarding destructor of base class?





39. Which of the following two entities (reading from Left to Right) can be connected by the dot operator?





40. How can we make a class abstract?





Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution