OOP Using C++ — MCQ Practice

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

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

Question 1846

EN + हिं
GB What is the output: class I{public:virtual void exec()=0; virtual ~I()=default;}; class Greet:public I{string n;public:Greet(string s):n(s){} void exec()override{cout<<"Hi "+n;}}; queue>q; q.push(make_unique("A")); q.push(make_unique("B")); while(!q.empty()){q.front()->exec();q.pop();}
IN आउटपुट क्या है: क्लास I{public:virtual void exec()=0; आभासी ~I()=डिफ़ॉल्ट;}; क्लास ग्रीट:पब्लिक I{स्ट्रिंग n;पब्लिक:ग्रीट(स्ट्रिंग s):n(s){} void exec()ओवरराइड{cout
Hi AHi B हाय एहाय बी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
Hi A Hi B हाय ए हाय बी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) FIFO: Hi A then Hi B. Output: Hi AHi B.
व्याख्या (हिन्दी) फीफो: हाय ए, फिर हाय बी। आउटपुट: हाय ए, हाय बी।
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1847

EN + हिं
GB What is the output: template class Lazy2{mutable optionalcache; functionfn; public:Lazy2(functionf):fn(f){} T get()const{if(!cache)cache=fn();return *cache;}}; int c=0; Lazy2l([&c](){return ++c;}); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Lazy2{म्यूटेबल ऑप्शनल कैश; functionfn; सार्वजनिक:Lazy2(functionf):fn(f){} T get()const{if(!cache)cache=fn();return *cache;}}; पूर्णांक सी=0; Lazy2l([&c](){रिटर्न++c;}); अदालत
111 111
121 121
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First get(): c=1,cache=1. Second: from cache=1. c=1. Output: 111.
व्याख्या (हिन्दी) सबसे पहले प्राप्त करें(): c=1,cache=1. दूसरा: कैश से=1. सी=1. आउटपुट: 111.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1848

EN + हिं
GB What is the output: template auto transform_pair(pairp,functionf,functiong){return make_pair(f(p.first),g(p.second));} auto r=transform_pair({5,"hi"},[](int x){return x*2;},[](string s){return s+"!";}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ट्रांसफॉर्म_पेयर(पेयरप,फंक्शनएफ,फंक्शनजी){रिटर्न मेक_पेयर(एफ(पी.फर्स्ट),जी(पी.सेकेंड));} ऑटो आर=ट्रांसफॉर्म_पेयर({5,"हाय"},[](इंट एक्स){रिटर्न x*2;},[](स्ट्रिंग एस){रिटर्न एस+"!";}); अदालत
10hi! 10हाय!
5hi 5हाय
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; "hi"+"!"="hi!". Output: 10hi!.
व्याख्या (हिन्दी) 5*2=10; "हाय"+"!"="हाय!"। आउटपुट: 10हाय!
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1849

EN + हिं
GB What is the output: try{int x=5,y=0;if(!y)throw domain_error("div0");cout<
IN आउटपुट क्या है: Try{int x=5,y=0;if(!y)throw Domain_error("div0");cout
div0 div0
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Throws domain_error. Output: div0.
व्याख्या (हिन्दी) डोमेन_त्रुटि फेंकता है। आउटपुट: div0.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1850

EN + हिं
GB What is the output: try{vectorv={1,2,3};cout<
IN आउटपुट क्या है: Try{vectorv={1,2,3};cout
O हे
E
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) at(5) on size-3 vector: out_of_range. Output: O.
व्याख्या (हिन्दी) at(5) आकार-3 वेक्टर पर: out_of_range। आउटपुट: ओ.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1851

EN + हिं
GB What is the output: struct A{~A()noexcept{cout<<'D';}}; try{A a;throw 1;}catch(int){cout<<'C';}
IN आउटपुट क्या है: struct A{~A()noexcept{cout
DC डीसी
CD सीडी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwind: ~A=D; catch: C. Output: DC.
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~ए=डी; कैच: सी. आउटपुट: डीसी.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1852

EN + हिं
GB What is the output: int f()noexcept{return 42;} try{cout<
IN आउटपुट क्या है: int f()noexcept{return 42;} Try{cout
42 42
X एक्स
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() returns 42, no throw. Output: 42.
व्याख्या (हिन्दी) f() 42 लौटाता है, कोई थ्रो नहीं। आउटपुट: 42.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1853

EN + हिं
GB What is the output: auto safe=[](auto f,auto... args)->optional{try{return f(args...);}catch(...){return nullopt;}}; auto r=safe([](int x,int y)->int{if(!y)throw 1;return x/y;},10,0); cout<
IN आउटपुट क्या है: ऑटो सेफ=[](ऑटो एफ,ऑटो...आर्ग्स)->वैकल्पिक{प्रयास{रिटर्न एफ(आर्ग्स...);}कैच(...){रिटर्न नॉलॉप्ट;}}; ऑटो आर=सुरक्षित([](int x,int y)->int{if(!y)throw 1;return x/y;},10,0); अदालत
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Throws; returns nullopt. has_value=0. Output: 0.
व्याख्या (हिन्दी) फेंकता है; शून्य लौटाता है। has_value=0. आउटपुट: 0.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1854

EN + हिं
GB What is the output: try{string s=string(1,'A'); s.at(5);}catch(out_of_range&){cout<<'O';}
IN आउटपुट क्या है: Try{string s=string(1,'A'); s.at(5);}कैच(out_of_range&){cout
O हे
A
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) s.at(5) on size-1 string: out_of_range. Output: O.
व्याख्या (हिन्दी) s.at(5) आकार-1 स्ट्रिंग पर: out_of_range। आउटपुट: ओ.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1855

EN + हिं
GB What is the output: int n=0; try{for(int i=0;i<5;i++){n++;if(n==3)throw n;}}catch(int x){cout<
IN आउटपुट क्या है: int n=0; प्रयास करें{for(int i=0;i
33 33
35 35
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Throws when n==3. x=3,n=3. Output: 33.
व्याख्या (हिन्दी) फेंकता है जब n==3. एक्स=3,एन=3. आउटपुट: 33.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1856

EN + हिं
GB What is the output: class E:public runtime_error{public:E(string s):runtime_error(s){}}; try{throw E("myerr");}catch(E& e){cout<
IN आउटपुट क्या है: क्लास ई:पब्लिक रनटाइम_एरर{पब्लिक:ई(स्ट्रिंग एस):रनटाइम_एरर(एस){}}; प्रयास करें{फेंकें E("myerr");}पकड़ें(E& e){cout
myerr मायर
E
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.what()=myerr. Output: myerr.
व्याख्या (हिन्दी) e.what()=myerr. आउटपुट: मायर.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1857

EN + हिं
GB What is the output: int x=0; try{x=1;try{x=2;throw 1;x=3;}catch(int){x=4;}} cout<
IN आउटपुट क्या है: int x=0; प्रयास करें {x = 1; प्रयास करें {x = 2; फेंकें 1;
4 4
2 2
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1,2; throw; x=4. Output: 4.
व्याख्या (हिन्दी) एक्स=1,2; फेंक; एक्स=4. आउटपुट: 4.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1858

EN + हिं
GB What is the output: void f(){try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: void f(){try{throw 1;}catch(int i){cout
111 111
1 11 1 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f: catch prints 1, throws 11. Outer: catches 11. Output: 111.
व्याख्या (हिन्दी) एफ: कैच प्रिंट 1, थ्रो 11. आउटर: कैच 11. आउटपुट: 111.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1859

EN + हिं
GB What is the output: try{auto p=make_unique(5); throw *p;}catch(int i){cout<
IN आउटपुट क्या है: Try{auto p=make_unique(5); फेंको *p;}पकड़ो(int i){cout
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw *p throws int 5. Output: 5.
व्याख्या (हिन्दी) थ्रो *पी थ्रो इंट 5. आउटपुट: 5.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1860

EN + हिं
GB What is the output: struct Guard{int& r; Guard(int& x):r(x){r=1;} ~Guard(){r=2;}}; int x=0; try{Guard g(x); throw 1;}catch(int){cout<
IN आउटपुट क्या है: structguard{int& r; गार्ड(int& x):r(x){r=1;} ~गार्ड(){r=2;}}; int x=0; कोशिश करें {गार्ड जी (एक्स); फेंको 1;}पकड़ो(int){cout
2 2
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ~Guard: r=2. catch: cout<
व्याख्या (हिन्दी) ~गार्ड: r=2. पकड़ो: कोउट
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।