cpp-programming-constructors-and-destructors Related Question Answers

26. To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .






27. Which of the following statement is correct about constructors?





28. Which of the following statement is correct whenever an object goes out of scope?





29. What will be the output of the following program? #include<iostream.h> class IndiaBix { int x; public: IndiaBix(int xx, float yy) { cout<< char(yy); } }; int main() { IndiaBix p = new IndiaBix(35, 99.50f); return 0; }





30. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { public: IndiaBix() { cout<< "India"; } ~IndiaBix() { cout<< "Bix"; } }; int main() { IndiaBix objBix; return 0; }





31. Which of the following statement is correct about the program given below? #include<iostream.h> class Bix { int x; public: Bix(); ~Bix(); void Show() const; }; Bix::Bix() { x = 25; } void Bix::Show() const { cout<< x; } int main() { Bix objB; objB.Show(); return 0; }





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





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






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





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





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






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






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





39. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x; public: IndiaBix(short ss) { cout<< "Short" << endl; } IndiaBix(int xx) { cout<< "Int" << endl; } IndiaBix(char ch) { cout<< "Char" << endl; } ~IndiaBix() { cout<< "Final"; } }; int main() { IndiaBix ptr = new IndiaBix('B'); return 0; }






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






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






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






43. What will be the out of the following program? #include<iostream.h> class BixBase { protected: int x, y; public: BixBase(int xx = 0, int yy = 0) { x = xx; y = yy; } void Show() { cout<< x this->y << endl; } }; class BixDerived { private: BixBase objBase; public: BixDerived(int xx, int yy) : objBase(xx, yy) { objBase.Show(); } ~BixDerived() { } }; int main() { BixDerived objDev(10, 20); return 0; }






44. Which of the following statement is correct about the program given below? #include<iostream.h> 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; }





45. Which of the following statement is correct about the program given below? #include<iostream.h> 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; }





46. What will be the out of the following program? #include<iostream.h> class BixBase { public: int x, y; public: BixBase(int xx = 0, int yy = 0) { x = xx; y = yy; } }; class BixDerived : public BixBase { private: BixBase objBase; public: BixDerived(int xx, int yy) : BixBase(xx), objBase(yy) { cout << this->x << " " << this->y << " " << objBase.x << " " << objBase.y << " "; } ~BixDerived() { } }; int main() { BixDerived objDev(11, 22); return 0; }






47. A constructor that accepts __________ parameters is called the default constructor.





48. 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?





49. Can a class have virtual destructor?



50. Destructor has the same name as the constructor and it is preceded by ______ .





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