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 61

EN + हिं
GB What is the output: class T{public: T(){cout<<'T';} T(const T&){cout<<'C';} ~T(){cout<<'D';}}; T f(T t){return t;} T a; f(a);
IN आउटपुट क्या है: क्लास टी{पब्लिक: टी(){काउट
TCCDD टीसीसीडीडी
Depends on optimization अनुकूलन पर निर्भर करता है
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) With NRVO: T constructed (T), copy to param (C), copy return (C or elided), destructors. Optimization dependent.
व्याख्या (हिन्दी) एनआरवीओ के साथ: टी निर्मित (टी), कॉपी टू पैरा (सी), कॉपी रिटर्न (सी या एलिडेड), डिस्ट्रक्टर्स। अनुकूलन निर्भर.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 62

EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v*v){}}; A a(4); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v*v){}}; ए ए(4); अदालत
16 16
4 4
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=4*4=16. Output: 16.
व्याख्या (हिन्दी) x=4*4=16. आउटपुट: 16.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 63

EN + हिं
GB What is the output: class A{public:A(){cout<<1;} A(int){cout<<2;} A(int,int){cout<<3;}}; A a; A b(1); A c(1,2);
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
123 123
111 111
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a: default=1; b(1): int=2; c(1,2): int,int=3. Output: 123.
व्याख्या (हिन्दी) ए: डिफ़ॉल्ट=1; बी(1): int=2; सी(1,2): int,int=3. आउटपुट: 123.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 64

EN + हिं
GB What is the output: class A{public:int x; constexpr A(int v):x(v){}}; constexpr A a(5); cout<
IN आउटपुट क्या है: class A{public:int x; constexpr A(int v):x(v){}}; constexpr ए ए(5); अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexpr ctor creates a at compile time. a.x=5. Output: 5.
व्याख्या (हिन्दी) संकलन समय पर constexpr ctor एक बनाता है। a.x=5. आउटपुट: 5.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 65

EN + हिं
GB What is the output: class A{public:int x=0;}; class B:public A{public:B(){x=5;}}; B b; cout<
IN आउटपुट क्या है: class A{public:int x=0;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:बी(){x=5;}}; बी बी; अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B() sets x=5. Output: 5.
व्याख्या (हिन्दी) बी() x=5 सेट करता है। आउटपुट: 5.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 66

EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x*2){}}; A a(3); A b(a); A c(b); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x*2){}}; ए ए(3); ए बी(ए); ए सी(बी); अदालत
3612 3612
336 336
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=3; b.x=3*2=6; c.x=6*2=12. Output: 3612.
व्याख्या (हिन्दी) a.x=3; b.x=3*2=6; c.x=6*2=12. आउटपुट: 3612.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 67

EN + हिं
GB What is the output: class A{int x=0; public: A&operator=(int v){x=v;return *this;} int get()const{return x;}}; A a; a=5; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: A&operator=(int v){x=v;return *this;} int get()const{return x;}}; ए ए; ए=5; अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=5: operator=(5): x=5. Output: 5.
व्याख्या (हिन्दी) a=5: ऑपरेटर=(5): x=5. आउटपुट: 5.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 68

EN + हिं
GB What is the output: class A{public:~A(){cout<<'X';} A()=default; A(A&&)=default;}; A f(){return A();} A a=f(); cout<<'Y';
IN आउटपुट क्या है: क्लास ए{पब्लिक:~ए(){काउट
XY XY
YX YX
Y वाई
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory elision: no move/copy needed. a created directly. At end: ~a prints X. But cout<<'Y' first. Output: YX.
व्याख्या (हिन्दी) C++17 अनिवार्य एलिज़न: कोई स्थानांतरण/प्रतिलिपि की आवश्यकता नहीं है। एक सीधे बनाया गया. अंत में: ~a X प्रिंट करता है। लेकिन कॉउट
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 69

EN + हिं
GB What is the output: class A{public:int x; A():x(0){} A(int v):x(v){}}; A arr[3]={1,2,3}; cout<
IN आउटपुट क्या है: class A{public:int x; A():x(0){} A(int v):x(v){}}; एक गिरफ्तारी[3]={1,2,3}; अदालत
13 13
31 31
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) arr[0].x=1, arr[2].x=3. Output: 13.
व्याख्या (हिन्दी) गिरफ्तारी[0].x=1, गिरफ्तारी[2].x=3. आउटपुट: 13.
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 70

EN + हिं
GB What is the output: class A{public:int x=0; ~A(){x=-1;} int getAfterDtor(){return x;}}; A *p=new A; delete p; // p->getAfterDtor() would be UB
IN आउटपुट क्या है: class A{public:int x=0; ~A(){x=-1;} int getAfterDtor(){return x;}}; ए *पी=नया ए; पी हटाएं; // p->getAfterDtor() यूबी होगा
Undefined behavior अपरिभाषित व्यवहार
-1 -1
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Accessing deleted object is UB.
व्याख्या (हिन्दी) हटाए गए ऑब्जेक्ट तक पहुंच यूबी है।
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 71

EN + हिं
GB What is the output: class A{public:int x; constexpr A(int v):x(v*v){}}; constexpr A a(4); cout<
IN आउटपुट क्या है: class A{public:int x; constexpr A(int v):x(v*v){}}; constexpr ए ए(4); अदालत
16 16
4 4
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexpr A(4): x=16. Output: 16.
व्याख्या (हिन्दी) constexpr A(4): x=16. आउटपुट: 16.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 72

EN + हिं
GB What is the output: class A{public:int x=0,y=0; A()=default; A(int a,int b):x(a),y(b){}}; A a{3,4}; cout<
IN आउटपुट क्या है: class A{public:int x=0,y=0; ए()=डिफ़ॉल्ट; A(int a,int b):x(a),y(b){}}; ए ए{3,4}; अदालत
34 34
Compile error संकलन त्रुटि
Undefined अपरिभाषित
00 00
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A has user-provided constructor so not aggregate; A a{3,4} calls A(int,int). Output: 34.
व्याख्या (हिन्दी) A के पास उपयोगकर्ता द्वारा प्रदत्त कंस्ट्रक्टर है इसलिए समग्र नहीं; A a{3,4} A(int,int) को कॉल करता है। आउटपुट: 34.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 73

EN + हिं

Question 74

EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} bool operator<(const A& o)const{return x
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} बूल ऑपरेटर
1 1
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min uses operator<; min is c.x=1. Output: 1.
व्याख्या (हिन्दी) न्यूनतम ऑपरेटर का उपयोग करता है
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 75

EN + हिं
GB What is the output: class A{public:int x=10; A(const A& o):x(o.x-1){} A()=default;}; A a; A b=a; A c=b; A d=c; cout<
IN आउटपुट क्या है: class A{public:int x=10; A(const A&o):x(o.x-1){} A()=default;}; ए ए; ए बी=ए; ए सी=बी; ए डी=सी; अदालत
10 9 8 7 10 9 8 7
Compile error संकलन त्रुटि
Undefined अपरिभाषित
option_b विकल्प_बी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) See explanation.
व्याख्या (हिन्दी) स्पष्टीकरण देखें.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।