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 1

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

Question 2

EN + हिं
GB What happens when no catch handler matches a thrown exception?
IN क्या होता है जब कोई कैच हैंडलर फेंके गए अपवाद से मेल नहीं खाता?
Program continues कार्यक्रम जारी है
std::terminate is called std::terminet कहा जाता है
Exception is silently ignored अपवाद को चुपचाप नजरअंदाज कर दिया जाता है
Default catch is used डिफ़ॉल्ट कैच का उपयोग किया जाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) If no handler matches (and no catch-all ...), std::terminate() is called, ending the program.
व्याख्या (हिन्दी) यदि कोई हैंडलर मेल नहीं खाता (और कोई कैच-ऑल नहीं...), तो std::terminet() को कॉल किया जाता है, जिससे प्रोग्राम समाप्त हो जाता है।
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Exception Handling" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 3

EN + हिं
GB What is the output: try{try{throw 1.0;}catch(int){cout<<'I';}}catch(double){cout<<'D';}
IN आउटपुट क्या है: प्रयास करें {प्रयास करें {थ्रो 1.0;} पकड़ें (int) {काउट
I मैं
D डी
ID पहचान
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1.0 is double; inner catch(int) doesn't match; propagates to outer catch(double). Output: D.
व्याख्या (हिन्दी) 1.0 दोगुना है; आंतरिक कैच(इंट) मेल नहीं खाता; बाहरी कैच (डबल) तक फैलता है। आउटपुट: डी.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Exception Handling" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 4

EN + हिं
GB What is 'exception safety guarantee'?
IN 'अपवाद सुरक्षा गारंटी' क्या है?
Level of guarantee a function provides about state when exception thrown अपवाद फेंके जाने पर कोई फ़ंक्शन स्थिति के बारे में गारंटी का स्तर प्रदान करता है
Catching all exceptions सभी अपवादों को पकड़ना
noexcept specification विशिष्टता को छोड़कर कोई नहीं
Stack unwinding ढेर खोलना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Levels: basic (no leak), strong (transaction), nothrow (never throws). Exception safety is about invariant preservation.
व्याख्या (हिन्दी) स्तर: बुनियादी (कोई रिसाव नहीं), मजबूत (लेन-देन), नोथ्रो (कभी नहीं फेंकता)। अपवाद सुरक्षा अपरिवर्तनीय संरक्षण के बारे में है।
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 5

EN + हिं
GB What is the output: struct A{~A(){cout<<'D';}}; try{A a; throw 1;}catch(int){cout<<'C';}
IN आउटपुट क्या है: struct A{~A(){cout
CD सीडी
DC डीसी
C सी
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwinding destroys a (prints D) before catch handler executes (prints C). Output: DC.
व्याख्या (हिन्दी) कैच हैंडलर निष्पादित (प्रिंट सी) से पहले स्टैक अनवाइंडिंग (प्रिंट डी) को नष्ट कर देता है। आउटपुट: डीसी.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Exception Handling" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 6

EN + हिं
GB What is the output: try{throw;}catch(int){cout<<'I';}catch(...){cout<<'A';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (int) {काउट
A
I मैं
std::terminate एसटीडी::समाप्त
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; with no active exception calls std::terminate().
व्याख्या (हिन्दी) फेंक; बिना किसी सक्रिय अपवाद के std::termine() कॉल करता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Exception Handling" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 7

EN + हिं
GB What is 'catch-all' handler in C++?
IN C++ में 'कैच-ऑल' हैंडलर क्या है?
catch(...) — catches any exception type पकड़ो(...) - किसी भी अपवाद प्रकार को पकड़ता है
catch(void) पकड़ना(शून्य)
catch(exception) पकड़ो (अपवाद)
Catching by value मूल्य के आधार पर पकड़ना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) catch(...) catches any exception type including non-class exceptions.
व्याख्या (हिन्दी) कैच(...) गैर-वर्ग अपवादों सहित किसी भी अपवाद प्रकार को पकड़ता है।
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 8

EN + हिं
GB What is the output: void f(){throw string("Error");} try{f();}catch(const string& s){cout<
IN आउटपुट क्या है: void f(){throw string("Error");} Try{f();}catch(const string& s){cout
Error गलती
Compile error संकलन त्रुटि
Undefined अपरिभाषित
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() throws string. catch catches by const ref, prints Error. Output: Error.
व्याख्या (हिन्दी) f() स्ट्रिंग फेंकता है। कॉन्स्ट रेफरी द्वारा कैच पकड़ें, त्रुटि प्रिंट करें। आउटपुट: त्रुटि.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Exception Handling" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 9

EN + हिं
GB What is 'stack unwinding'?
IN 'स्टैक अनवाइंडिंग' क्या है?
Destructors called for local objects as exception propagates अपवाद प्रसार के रूप में विध्वंसकों ने स्थानीय वस्तुओं को बुलाया
Recursive function termination पुनरावर्ती कार्य समाप्ति
Stack overflow handling स्टैक ओवरफ्लो प्रबंधन
Memory deallocation मेमोरी डिलोकेशन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwinding: as exception propagates, destructors are called for all local objects in the chain of scopes.
व्याख्या (हिन्दी) स्टैक अनवाइंडिंग: जैसे-जैसे अपवाद फैलता है, स्कोप की श्रृंखला में सभी स्थानीय वस्तुओं के लिए डिस्ट्रक्टर्स को बुलाया जाता है।
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Exception Handling" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 10

EN + हिं
GB What is the output: class E{public: string msg; E(string s):msg(s){}}; try{throw E("Oops");}catch(E& e){cout<
IN आउटपुट क्या है: वर्ग ई {सार्वजनिक: स्ट्रिंग संदेश; ई(स्ट्रिंग s):msg(s){}}; प्रयास करें{फेंकें E("उफ़");}पकड़ें(E& e){cout
Oops उफ़
E
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) E(Oops) thrown and caught by reference. e.msg=Oops. Output: Oops.
व्याख्या (हिन्दी) ई(उफ़) संदर्भ द्वारा फेंका और पकड़ा गया। e.msg=उफ़. आउटपुट: उफ़.
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 11

EN + हिं
GB What is the output: try{throw 1;}catch(int& i){i=99; cout<
IN आउटपुट क्या है: Try{throw 1;}catch(int& i){i=99; अदालत
99 99
1 1
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) catch by reference; modify i=99; print i=99. Output: 99.
व्याख्या (हिन्दी) संदर्भ द्वारा पकड़ें; संशोधित करें i=99; i=99 प्रिंट करें। आउटपुट: 99.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Exception Handling" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 12

EN + हिं
GB What is 'exception specification' in C++?
IN C++ में 'अपवाद विशिष्टता' क्या है?
noexcept or noexcept(expr) declaring function won't throw noexcept या noexcept(expr) घोषित करने वाला फ़ंक्शन नहीं फेंकेगा
throw() specification (deprecated) फेंक() विशिष्टता (अप्रत्याशित)
Try-catch inside function फ़ंक्शन के अंदर पकड़ने का प्रयास करें
Exception class hierarchy अपवाद वर्ग पदानुक्रम
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) noexcept specifier (C++11) declares a function doesn't throw; violations call terminate().
व्याख्या (हिन्दी) noexcept विनिर्देशक (C++11) घोषित करता है कि कोई फ़ंक्शन फेंकता नहीं है; उल्लंघन कॉल समाप्त()।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Exception Handling" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 13

EN + हिं
GB What is the output: auto f=[]()noexcept{throw 1;}; try{f();}catch(...){cout<<'C';}
IN आउटपुट क्या है: auto f=[]()noexcept{throw 1;}; प्रयास करें{f();}पकड़ो(...){cout
C सी
std::terminate called std::समाप्त बुलाया गया
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) noexcept function throwing calls std::terminate, not caught by catch.
व्याख्या (हिन्दी) noexcept फ़ंक्शन थ्रोइंग कॉल std::समाप्त, कैच द्वारा नहीं पकड़ा गया।
🎯 Exam Perspective
OOP Using C++ ("Exception Handling" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 14

EN + हिं
GB What is 'std::exception_ptr'?
IN 'std::exception_ptr' क्या है?
Pointer-like type that can store and rethrow exceptions पॉइंटर जैसा प्रकार जो अपवादों को संग्रहीत और पुनर्स्थापित कर सकता है
Base class for all exceptions सभी अपवादों के लिए बेस क्लास
Exception handling overhead ओवरहेड अपवाद हैंडलिंग
Stack pointer during exception अपवाद के दौरान स्टैक सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::exception_ptr enables storing and rethrowing exceptions across threads or callbacks.
व्याख्या (हिन्दी) std::exception_ptr थ्रेड या कॉलबैक में अपवादों को संग्रहीत करने और पुनर्स्थापित करने में सक्षम बनाता है।
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Exception Handling" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 15

EN + हिं
GB What is the output: try{int*p=nullptr; *p=1;}catch(runtime_error& e){cout<<'R';}catch(...){cout<<'A';}
IN आउटपुट क्या है: Try{int*p=nullptr; *p=1;}catch(runtime_error& e){cout
R आर
A
std::terminate एसटीडी::समाप्त
Undefined behavior (no exception) अपरिभाषित व्यवहार (कोई अपवाद नहीं)
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Dereferencing null pointer is undefined behavior; it does NOT throw a C++ exception — it likely causes a crash/signal.
व्याख्या (हिन्दी) अशक्त सूचक को संदर्भित करना अपरिभाषित व्यवहार है; यह C++ अपवाद नहीं फेंकता - यह संभावित रूप से क्रैश/सिग्नल का कारण बनता है।
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Exception Handling" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।