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 76

EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){cout<<'C';} ~A(){cout<<'D';} A(A&&o):x(o.x){o.x=0;cout<<'M';}}; A f(){return A(5);} A a=f(); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){cout
C5 सी 5
CM5 सीएम5
CCD5 सीसीडी5
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory elision: only one C, no move. a.x=5. Output: C5D (D at scope end, but question asks output before scope end: C5).
व्याख्या (हिन्दी) C++17 अनिवार्य एलिशन: केवल एक C, कोई चाल नहीं। a.x=5. आउटपुट: C5D (D स्कोप अंत में है, लेकिन प्रश्न स्कोप अंत से पहले आउटपुट पूछता है: C5)।
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 77

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

Question 78

EN + हिं
GB What is the output: class A{public:int x; A():x(0){cout<<'D';} A(int v):x(v){cout<<'P';} A(const A&o):x(o.x){cout<<'C';}}; A a=5;
IN आउटपुट क्या है: class A{public:int x; A():x(0){cout
P पी
C सी
D डी
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A a=5: copy-initialization from int: A(int) called. Output: P.
व्याख्या (हिन्दी) A a=5: int से कॉपी-इनिशियलाइज़ेशन: A(int) कहा जाता है। आउटपुट: पी.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 79

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

Question 80

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

Question 81

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

Question 82

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

Question 83

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

Question 84

EN + हिं
GB What is the output: class A{public:int x=0; ~A(){x=-1;} void print(){cout<x=5; p->print(); delete p; cout<x;
IN आउटपुट क्या है: class A{public:int x=0; ~A(){x=-1;} void print(){coutprint(); पी हटाएं; अदालत
5 then UB 5 फिर यूबी
Compile error संकलन त्रुटि
5-1 5-1
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) print()=5; after delete: p->x is UB. Output: 5 then UB.
व्याख्या (हिन्दी) प्रिंट()=5; हटाने के बाद: p->x UB है। आउटपुट: 5 फिर यूबी।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 85

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
123-3-2-1 123-3-2-1
123321 123321
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Constructed: 1,2,3. Destroyed reverse: -3,-2,-1. Output: 123-3-2-1.
व्याख्या (हिन्दी) निर्मित: 1,2,3. नष्ट उल्टा:-3,-2,-1. आउटपुट: 123-3-2-1.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 86

EN + हिं
510 510
010 010
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Moved correctly. v[0].x=5,v[1].x=10. Output: 510.
व्याख्या (हिन्दी) सही ढंग से चला गया. v[0].x=5,v[1].x=10. आउटपुट: 510.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 87

EN + हिं
GB What is the output: class A{int* p; public:A(int v):p(new int(v)){} ~A(){delete p;} A(const A& o):p(new int(*o.p)){} int get()const{return *p;}}; A a(5); A b=a; *b.p=10; cout<
IN आउटपुट क्या है: class A{int* p; सार्वजनिक:ए(int v):p(नया int(v)){} ~A(){delete p;} A(const A& o):p(new int(*o.p)){} int get()const{return *p;}}; ए ए(5); ए बी=ए; *बी.पी=10; अदालत
510 510
1010 1010
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Deep copy: b has own int. *b.p=10. a unchanged=5. Output: 510.
व्याख्या (हिन्दी) डीप कॉपी: बी का अपना इंट है। *बी.पी=10. एक अपरिवर्तित=5. आउटपुट: 510.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 88

EN + हिं
GB What is the output: class A{public:int x; A():x(0){cout<<'0';} A(int v):x(v){cout<<'I';} ~A(){cout<<'D';}}; A arr[3];
IN आउटपुट क्या है: class A{public:int x; A():x(0){cout
000DDD 000डीडीडी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
0I0DDD 0आई0डीडीडी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3 default ctors: 000. 3 dtors: DDD. Output: 000DDD.
व्याख्या (हिन्दी) 3 डिफ़ॉल्ट ctors: 000. 3 dtors: DDD. आउटपुट: 000DDD.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 89

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

Question 90

EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(A&& o):x(exchange(o.x,0)){}}; A a(5); A b=move(a); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(A&& o):x(exchange(o.x,0)){}}; ए ए(5); ए बी = चाल (ए); अदालत
05 05
50 50
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) exchange(a.x,0) returns 5, sets a.x=0. b.x=5. Output: 05.
व्याख्या (हिन्दी) एक्सचेंज(a.x,0) 5 लौटाता है, a.x=0 सेट करता है। बी.एक्स=5. आउटपुट: 05.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।