31 Question 31 EN + हिं GB What is the output: class A{public: A(){cout<<1;} A(const A&){cout<<2;} ~A(){cout<<3;}}; A f(A a){return a;} A b; f(b); IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट A 1 2 3 2 3 3 (numbers) 1 2 3 2 3 3 (संख्याएँ) B 123233 123233 C Depends on optimization अनुकूलन पर निर्भर करता है D 12233 12233 ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) With NRVO and copy elision, actual output depends on optimization level. Without optimization: construct b(1), copy to a(2), copy return(2), destroy return(3), destroy a(3), eventually destroy b(3). Output varies with optimization. व्याख्या (हिन्दी) एनआरवीओ और कॉपी एलिज़न के साथ, वास्तविक आउटपुट अनुकूलन स्तर पर निर्भर करता है। अनुकूलन के बिना: b(1) बनाएं, a(2) में कॉपी करें, रिटर्न कॉपी करें(2), रिटर्न नष्ट करें(3), a(3) नष्ट करें, अंततः b(3) नष्ट करें। आउटपुट अनुकूलन के साथ बदलता रहता है। 🎯 Exam Perspective OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो। 🔗 Related Questions What is the output: class A{public:int x; A():x(0){cout What is the output: struct A{int x; ~A(){cout What is the order of member initialization? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
32 Question 32 EN + हिं GB What is the output: class A{public:int x; A(int v=5):x(v){} }; A a,b(10); cout< IN आउटपुट क्या है: class A{public:int x; A(int v=5):x(v){} }; ए ए,बी(10); अदालत A 510 510 B 1010 1010 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) a.x=5(default), b.x=10. Output: 510. व्याख्या (हिन्दी) a.x=5(डिफ़ॉल्ट), b.x=10. आउटपुट: 510. 🎯 Exam Perspective SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें। 🔗 Related Questions What is the output: class A{public:int x=10; A(int v):x... What is the output: struct A{int x; ~A(){cout What is the output: class A{public:A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
33 Question 33 EN + हिं GB What is the output: class A{public:~A(){cout<<'D';}}; {A a; {A b;}} IN आउटपुट क्या है: क्लास ए{पब्लिक:~ए(){काउट A DD डीडी B D डी C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Inner b destroyed first (D), then outer a (D). Output: DD. व्याख्या (हिन्दी) पहले आंतरिक बी नष्ट हो गया (डी), फिर बाहरी ए (डी)। आउटपुट:डीडी. 🎯 Exam Perspective अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें। 🔗 Related Questions What is the output: class A{public:int x; A(int v):x(v)... What is the output: class A{int* p; public: A():p(new i... What is 'copy-and-swap idiom'? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
34 Question 34 EN + हिं GB What is the output: class A{public:int x,y; A(int a,int b):y(b),x(a){}}; A a(1,2); cout< IN आउटपुट क्या है: class A{public:int x,y; A(int a,int b):y(b),x(a){}}; ए ए(1,2); अदालत A 12 12 B 21 21 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Members initialized in declaration order (x then y), but initialized to a and b. x=1,y=2. Output: 12. व्याख्या (हिन्दी) सदस्यों को घोषणा क्रम (x फिर y) में आरंभ किया गया, लेकिन a और b से आरंभ किया गया। x=1,y=2. आउटपुट: 12. 🎯 Exam Perspective OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें। 🔗 Related Questions What is the output: class A{int* p; public: A():p(new i... What is the output: class A{public:int x; A(int v):x(v)... What is the output: class A{public:int x; A(int v):x(v)... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
35 Question 35 EN + हिं GB What is 'copy-and-swap idiom'? IN 'कॉपी-एंड-स्वैप मुहावरा' क्या है? A Implement assignment via copy ctor and swap for exception safety अपवाद सुरक्षा के लिए कॉपी सीटीआर और स्वैप के माध्यम से असाइनमेंट लागू करें B A sorting technique एक छँटाई तकनीक C A design pattern एक डिज़ाइन पैटर्न D A memory technique एक स्मृति तकनीक ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) A& operator=(A other){swap(*this,other);return *this;} — strong exception safety guaranteed. व्याख्या (हिन्दी) A& ऑपरेटर=(एक अन्य){स्वैप(*यह,अन्य);वापसी *यह;} - मजबूत अपवाद सुरक्षा की गारंटी। 🎯 Exam Perspective यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें। 🔗 Related Questions What is the output: class A{public:~A(){cout What is the output: class A{public:int x; A(int v):x(v)... What is the output: class A{int* p; public: A():p(new i... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
36 Question 36 EN + हिं GB What is the output: class A{public:int x; A():x(0){cout<<'D';} A(int v):x(v){cout<<'P';} ~A(){cout<<'X';}}; A a; A b(5); IN आउटपुट क्या है: class A{public:int x; A():x(0){cout A DPXX डीपीएक्सएक्स B DD डीडी C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) a: D; b: P. End of scope: ~b(X), ~a(X). Output: DPXX. व्याख्या (हिन्दी) ए: डी; बी: पी. दायरे का अंत: ~बी(एक्स), ~ए(एक्स)। आउटपुट: DPXX. 🎯 Exam Perspective यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें। 🔗 Related Questions What is the output: class A{int* p; public: A():p(new i... What is the output: class A{public:int x,y; A(int a,int... What is 'copy-and-swap idiom'? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
37 Question 37 EN + हिं GB What is the output: class A{int* p; public: A():p(new int(42)){} ~A(){delete p; cout<<'D';} int get(){return *p;}}; {A a; cout< IN आउटपुट क्या है: class A{int* p; सार्वजनिक: A():p(new int(42)){} ~A(){delete p; अदालत A 42D 42डी B D42 D42 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) get()=42; at scope end: ~A deletes and prints D. Output: 42D. व्याख्या (हिन्दी) प्राप्त()=42; स्कोप के अंत में: ~ए हटाता है और डी प्रिंट करता है। आउटपुट: 42डी। 🎯 Exam Perspective OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो। 🔗 Related Questions What is the output: class A{public: A(){cout What is 'delegating constructor'? What is the output: class A{public:~A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
38 Question 38 EN + हिं GB What is the order of member initialization? IN सदस्य आरंभीकरण का क्रम क्या है? A Declaration order in class, not initializer list order कक्षा में घोषणा क्रम, प्रारंभकर्ता सूची क्रम नहीं B Initializer list order आरंभकर्ता सूची क्रम C Alphabetical वर्णमाला D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Members initialized in declaration order regardless of the order in the initializer list. व्याख्या (हिन्दी) आरंभकर्ता सूची में क्रम की परवाह किए बिना सदस्यों ने घोषणा क्रम में आरंभ किया। 🎯 Exam Perspective Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें। 🔗 Related Questions What is the output: class A{public:~A(){cout What is the output: class A{public:int x,y; A(int a,int... What is the output: class A{public: A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
39 Question 39 EN + हिं GB What is the output: class A{public:int x; A(int v):x(v){cout< IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){cout A 3~ 3~ B 3 3 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Constructor prints 3; destructor prints ~ at end. Output: 3~. व्याख्या (हिन्दी) कंस्ट्रक्टर प्रिंट 3; विध्वंसक अंत में ~ प्रिंट करता है। आउटपुट: 3~. 🎯 Exam Perspective अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें। 🔗 Related Questions What is the output: class A{int* p; public: A():p(new i... What is 'virtual constructor idiom'? What is the order of member initialization? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
40 Question 40 EN + हिं GB What is 'virtual constructor idiom'? IN 'वर्चुअल कंस्ट्रक्टर मुहावरा' क्या है? A Clone pattern: virtual A* clone()=0; returns new derived copy क्लोन पैटर्न: वर्चुअल A* क्लोन()=0; नई व्युत्पन्न प्रतिलिपि लौटाता है B Calling virtual in ctor ctor में वर्चुअल कॉलिंग C Abstract factory सार कारखाना D Same as CRTP सीआरटीपी के समान ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Since constructors can't be virtual, clone() pattern provides polymorphic object creation. व्याख्या (हिन्दी) चूंकि कंस्ट्रक्टर वर्चुअल नहीं हो सकते, क्लोन() पैटर्न बहुरूपी ऑब्जेक्ट निर्माण प्रदान करता है। 🎯 Exam Perspective OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें। 🔗 Related Questions What is the output: class A{public:int x; A(int v):x(v)... What is the output: class A{public:int x,y; A(int a,int... What is the output: class A{int* p; public: A():p(new i... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
41 Question 41 EN + हिं GB What is the output: class A{public:A(){cout<<1;} ~A(){cout<<2;}}; class B:public A{public:B(){cout<<3;} ~B(){cout<<4;}}; B b; IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट A 1342 1342 B 3124 3124 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) A() prints 1, B() prints 3, ~B prints 4, ~A prints 2. Output: 1342. व्याख्या (हिन्दी) A() प्रिंट 1, B() प्रिंट 3, ~B प्रिंट 4, ~A प्रिंट 2. आउटपुट: 1342. 🎯 Exam Perspective यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें। 🔗 Related Questions What is 'delegating constructor'? What is the output: class A{public: A(){cout What is the output: struct A{int x; ~A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
42 Question 42 EN + हिं GB What is the output: class A{public:int x=10; A(int v):x(v){} A()=default;}; A a; A b(5); cout< IN आउटपुट क्या है: class A{public:int x=10; A(int v):x(v){} A()=default;}; ए ए; ए बी(5); अदालत A 105 105 B 510 510 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) a uses =default: x=10 (in-class). b(5): x=5. Output: 105. व्याख्या (हिन्दी) a =डिफ़ॉल्ट: x=10 (क्लास में) का उपयोग करता है। बी(5): एक्स=5. आउटपुट: 105. 🎯 Exam Perspective यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें। 🔗 Related Questions What is the output: class A{int* p; public: A():p(new i... What is the output: class A{public:int x,y; A(int a,int... What is the output: class A{public: A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
43 Question 43 EN + हिं GB What is the output: struct A{int x; ~A(){cout< IN आउटपुट क्या है: struct A{int x; ~ए(){काउट A 321 321 B 123 123 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Destructors in reverse order: c,b,a. Prints 3,2,1. Output: 321. व्याख्या (हिन्दी) उल्टे क्रम में विध्वंसक: सी, बी, ए। 3,2,1 प्रिंट करता है। आउटपुट: 321. 🎯 Exam Perspective OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो। 🔗 Related Questions What is the output: class A{public: A(){cout What is the output: class A{public:int x; A():x(0){cout What is 'delegating constructor'? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
44 Question 44 EN + हिं GB What is 'delegating constructor'? IN 'डेलीगेटिंग कंस्ट्रक्टर' क्या है? A Constructor calling another of same class: A():A(0){} कंस्ट्रक्टर उसी क्लास के दूसरे क्लास को कॉल कर रहा है: A():A(0){} B Calling base ctor आधार ctor को कॉल कर रहे हैं C Calling derived ctor व्युत्पन्न ctor को कॉल करना D Copy constructor कंस्ट्रक्टर कॉपी करें ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) C++11: A():A(0){} delegates to A(int); avoids code duplication. व्याख्या (हिन्दी) C++11: A():A(0){} A(int); कोड दोहराव से बचाता है। 🎯 Exam Perspective SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें। 🔗 Related Questions What is 'virtual constructor idiom'? What is the output: class A{public:int x; A(int v):x(v)... What is the output: class A{public:int x; A():x(0){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
45 Question 45 EN + हिं GB What is the output: class A{public:int x; A(int v):x(v){} A():A(99){}}; A a; cout< IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A():A(99){}}; ए ए; अदालत A 99 99 C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) A() delegates to A(99), x=99. Output: 99. व्याख्या (हिन्दी) A(), A(99), x=99 को दर्शाता है। आउटपुट: 99. 🎯 Exam Perspective अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें। 🔗 Related Questions What is the output: class A{public:int x=10; A(int v):x... What is 'virtual constructor idiom'? What is the output: class A{public:A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)