OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye.

📚 107 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
107 questions

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 आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
1 2 3 2 3 3 (numbers) 1 2 3 2 3 3 (संख्याएँ)
123233 123233
Depends on optimization अनुकूलन पर निर्भर करता है
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 न हो।

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); अदालत
510 510
1010 1010
Compile error संकलन त्रुटि
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 समझें।

Question 33

EN + हिं
GB What is the output: class A{public:~A(){cout<<'D';}}; {A a; {A b;}}
IN आउटपुट क्या है: क्लास ए{पब्लिक:~ए(){काउट
DD डीडी
D डी
Compile error संकलन त्रुटि
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 जरूर पढ़ें।

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); अदालत
12 12
21 21
Compile error संकलन त्रुटि
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 जरूर पढ़ें।

Question 35

EN + हिं
GB What is 'copy-and-swap idiom'?
IN 'कॉपी-एंड-स्वैप मुहावरा' क्या है?
Implement assignment via copy ctor and swap for exception safety अपवाद सुरक्षा के लिए कॉपी सीटीआर और स्वैप के माध्यम से असाइनमेंट लागू करें
A sorting technique एक छँटाई तकनीक
A design pattern एक डिज़ाइन पैटर्न
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 जरूर पढ़ें।

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
DPXX डीपीएक्सएक्स
DD डीडी
Compile error संकलन त्रुटि
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 दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

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; अदालत
42D 42डी
D42 D42
Compile error संकलन त्रुटि
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 न हो।

Question 38

EN + हिं
GB What is the order of member initialization?
IN सदस्य आरंभीकरण का क्रम क्या है?
Declaration order in class, not initializer list order कक्षा में घोषणा क्रम, प्रारंभकर्ता सूची क्रम नहीं
Initializer list order आरंभकर्ता सूची क्रम
Alphabetical वर्णमाला
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 समझें।

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
3~ 3~
3 3
Compile error संकलन त्रुटि
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 जरूर पढ़ें।

Question 40

EN + हिं
GB What is 'virtual constructor idiom'?
IN 'वर्चुअल कंस्ट्रक्टर मुहावरा' क्या है?
Clone pattern: virtual A* clone()=0; returns new derived copy क्लोन पैटर्न: वर्चुअल A* क्लोन()=0; नई व्युत्पन्न प्रतिलिपि लौटाता है
Calling virtual in ctor ctor में वर्चुअल कॉलिंग
Abstract factory सार कारखाना
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 जरूर पढ़ें।

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 आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
1342 1342
3124 3124
Compile error संकलन त्रुटि
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 जरूर पढ़ें।

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); अदालत
105 105
510 510
Compile error संकलन त्रुटि
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 दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 43

EN + हिं
GB What is the output: struct A{int x; ~A(){cout<
IN आउटपुट क्या है: struct A{int x; ~ए(){काउट
321 321
123 123
Compile error संकलन त्रुटि
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 न हो।

Question 44

EN + हिं
GB What is 'delegating constructor'?
IN 'डेलीगेटिंग कंस्ट्रक्टर' क्या है?
Constructor calling another of same class: A():A(0){} कंस्ट्रक्टर उसी क्लास के दूसरे क्लास को कॉल कर रहा है: A():A(0){}
Calling base ctor आधार ctor को कॉल कर रहे हैं
Calling derived ctor व्युत्पन्न ctor को कॉल करना
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 समझें।

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){}}; ए ए; अदालत
99 99
Compile error संकलन त्रुटि
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 जरूर पढ़ें।