OOP Using C++ — MCQ Practice

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

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

Question 76

EN + हिं
GB What is the output: try{string s=string(size_t(-1),'x');}catch(bad_alloc&){cout<<'M';}catch(length_error&){cout<<'L';}
IN आउटपुट क्या है: Try{string s=string(size_t(-1),'x');}catch( Bad_alloc&){cout
L एल
M एम
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size_t(-1) is UINT_MAX — too large; string throws length_error or bad_alloc. Most likely bad_alloc. Output: M.
व्याख्या (हिन्दी) size_t(-1) UINT_MAX है - बहुत बड़ा; स्ट्रिंग length_error या Bad_alloc फेंकती है। सबसे अधिक संभावना ख़राब_आवंटन। आउटपुट: एम.
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 77

EN + हिं
GB What is the output: try{stod("3.14");}catch(invalid_argument&){cout<<'I';}catch(...){cout<<'X';} cout<
IN आउटपुट क्या है: प्रयास करें {stod ("3.14");} पकड़ें (अमान्य_argument &) {cout
3.14 3.14
I मैं
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) stod("3.14") succeeds; no catch. cout outputs 3.14. Output: 3.14.
व्याख्या (हिन्दी) Stod('3.14') सफल होता है; कोई पकड़ नहीं. कॉउट आउटपुट 3.14. आउटपुट: 3.14.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Exception Handling" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 78

EN + हिं
GB What is the output: auto safe_div=[](int a,int b)->optional{if(b==0) return nullopt; return a/b;}; auto r=safe_div(10,3); cout<<(r?*r:-1);
IN आउटपुट क्या है: autosafe_div=[](int a,int b)-> वैकल्पिक{if(b==0) return nullopt; वापसी ए/बी;}; ऑटो r=safe_div(10,3); अदालत
3 3
-1 -1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b!=0: r=10/3=3. Output: 3.
व्याख्या (हिन्दी) बी!=0: आर=10/3=3. आउटपुट: 3.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Exception Handling" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 79

EN + हिं
GB What is the output: try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: Try{throw 1;}catch(int i){cout
121 121
12 12
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Outer catches 1 (prints 1); inner throws 2, catches (prints 2); then prints i=1 again. Output: 121.
व्याख्या (हिन्दी) बाहरी कैच 1 (प्रिंट 1); आंतरिक थ्रो 2, कैच (प्रिंट 2); फिर i=1 फिर से प्रिंट करता है। आउटपुट: 121.
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 80

EN + हिं
GB What is the output: class Ex{int c; public:Ex(int v):c(v){} int code()const{return c;}}; try{throw Ex(42);}catch(Ex& e){cout<
IN आउटपुट क्या है: class Ex{int c; सार्वजनिक:Ex(int ​​v):c(v){} int कोड()const{return c;}}; प्रयास करें{फेंकें Ex(42);}पकड़ें(Ex& e){cout
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.code()=42. Output: 42.
व्याख्या (हिन्दी) ई.कोड()=42. आउटपुट: 42.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Exception Handling" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 81

EN + हिं
GB What is the output: int x=0; try{x=1;if(x) throw 'E';x=2;}catch(char c){cout<
IN आउटपुट क्या है: int x=0; प्रयास करें{x=1;if(x) फेंक 'ई';x=2;}पकड़ें(char c){cout
E1 ई 1
E2 ई2
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1; throw 'E'; x=2 skipped; catch prints E; cout<
व्याख्या (हिन्दी) एक्स=1; 'ई' फेंको; x=2 छोड़ दिया गया; कैच प्रिंट ई; अदालत
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Exception Handling" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 82

EN + हिं
GB What is the output: struct RAII{int& r;RAII(int& x):r(x){r=1;} ~RAII(){r=0;}}; int x=0; try{RAII g(x); throw 1;}catch(int){cout<
IN आउटपुट क्या है: struct RAII{int& r;RAII(int& x):r(x){r=1;} ~RAII(){r=0;}}; int x=0; प्रयास करें{RAII g(x); फेंको 1;}पकड़ो(int){cout
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwind: ~RAII sets x=0. catch: cout<
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~RAII x=0 सेट करता है। पकड़ो: कोउट
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 83

EN + हिं
GB What is the output: try{try{throw runtime_error("err");}catch(logic_error&){cout<<'L';}}catch(runtime_error&e){cout<
IN आउटपुट क्या है: प्रयास करें {कोशिश करें {थ्रो रनटाइम_एरर ("इर्रर");}कैच (लॉजिक_एरर और) {काउट
err ग़लती होना
L एल
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner doesn't match; propagates to outer: err. Output: err.
व्याख्या (हिन्दी) भीतरी मेल नहीं खाता; बाहरी तक फैलता है: err. आउटपुट: ग़लती।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Exception Handling" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 84

EN + हिं
GB What is the output: auto f=[]()->expected{return 42;}; auto g=[]()->expected{return unexpected("fail");}; cout<
IN आउटपुट क्या है: auto f=[]()->expected{return 42;}; ऑटो g=[]()->अपेक्षित{वापसी अप्रत्याशित('असफल');}; अदालत
420 420
Compile error संकलन त्रुटि
Undefined अपरिभाषित
42 0 42 0
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f()=42; g() has no value. Output: 420.
व्याख्या (हिन्दी) एफ()=42; g() का कोई मूल्य नहीं है। आउटपुट: 420.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Exception Handling" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 85

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

Question 86

EN + हिं
GB What is the output: class A{public:~A()noexcept(false){throw 1;}}; try{A a;}catch(...){cout<<'X';}
IN आउटपुट क्या है: वर्ग A{सार्वजनिक:~A()noexcept(false){throw 1;}}; प्रयास करें{ए ए;}पकड़ो(...){कोउट
X एक्स
std::terminate एसटीडी::समाप्त
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Destructor throws; no active exception: std::terminate called. Output: terminate.
व्याख्या (हिन्दी) विध्वंसक फेंकता है; कोई सक्रिय अपवाद नहीं: std::terminet कहा गया। आउटपुट: समाप्त करें.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Exception Handling" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 87

EN + हिं
GB What is the output: void f()noexcept{cout<<1;} void g(){try{f();}catch(...){cout<<2;}} g();
IN आउटपुट क्या है: void f()noexcept{cout
1 1
12 12
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() doesn't throw; catch not entered. Output: 1.
व्याख्या (हिन्दी) f() फेंकता नहीं है; कैच दर्ज नहीं किया गया. आउटपुट: 1.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Exception Handling" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 88

EN + हिं
GB What is the output: try{int x=stoi("2147483648");}catch(out_of_range&){cout<<'O';}
IN आउटपुट क्या है: Try{int x=stoi('2147483648');}catch(out_of_range&){cout
O हे
Compile error संकलन त्रुटि
Undefined अपरिभाषित
2147483648 2147483648
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2147483648 > INT_MAX: stoi throws out_of_range. Output: O.
व्याख्या (हिन्दी) 2147483648 > INT_MAX: Stoi आउट_ऑफ़_रेंज फेंकता है। आउटपुट: ओ.
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 89

EN + हिं
GB What is the output: try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो 1;} कैच (इंट आई) {काउट
1 1
12 12
std::terminate एसटीडी::समाप्त
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw i+1 propagates outside the try-catch; no outer handler: terminate. Output: 1 then terminate.
व्याख्या (हिन्दी) थ्रो i+1 ट्राई-कैच के बाहर प्रचारित होता है; कोई बाहरी हैंडलर नहीं: समाप्त करें। आउटपुट: 1 फिर समाप्त करें।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Exception Handling" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 90

EN + हिं
GB What is the output: auto ex=make_exception_ptr(runtime_error("err")); try{rethrow_exception(ex);}catch(runtime_error& e){cout<
IN आउटपुट क्या है: auto ex=make_exception_ptr(runtime_error("err")); प्रयास करें{rethrow_exception(ex);}catch(runtime_error& e){cout
err ग़लती होना
Compile error संकलन त्रुटि
Undefined अपरिभाषित
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) rethrow_exception throws stored exception. Caught: err. Output: err.
व्याख्या (हिन्दी) rethrow_exception संग्रहीत अपवाद को फेंकता है। पकड़ा गया: ग़लती. आउटपुट: ग़लती।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Exception Handling" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।