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
406
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
A
CD सीडी
B
DC डीसी
C
C सी
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwinding destroys a (prints D) before catch handler executes (prints C). Output: DC.
व्याख्या (हिन्दी) कैच हैंडलर निष्पादित (प्रिंट सी) से पहले स्टैक अनवाइंडिंग (प्रिंट डी) को नष्ट कर देता है। आउटपुट: डीसी.
407
EN + हिं
GB What is the output: try{throw;}catch(int){cout<<'I';}catch(...){cout<<'A';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (int) {काउट
A
A
B
I मैं
C
std::terminate एसटीडी::समाप्त
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; with no active exception calls std::terminate().
व्याख्या (हिन्दी) फेंक; बिना किसी सक्रिय अपवाद के std::termine() कॉल करता है।
408
EN + हिं
GB What is 'catch-all' handler in C++?
IN C++ में 'कैच-ऑल' हैंडलर क्या है?
A
catch(...) — catches any exception type पकड़ो(...) - किसी भी अपवाद प्रकार को पकड़ता है
B
catch(void) पकड़ना(शून्य)
C
catch(exception) पकड़ो (अपवाद)
D
Catching by value मूल्य के आधार पर पकड़ना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) catch(...) catches any exception type including non-class exceptions.
व्याख्या (हिन्दी) कैच(...) गैर-वर्ग अपवादों सहित किसी भी अपवाद प्रकार को पकड़ता है।
409
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
A
Error गलती
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() throws string. catch catches by const ref, prints Error. Output: Error.
व्याख्या (हिन्दी) f() स्ट्रिंग फेंकता है। कॉन्स्ट रेफरी द्वारा कैच पकड़ें, त्रुटि प्रिंट करें। आउटपुट: त्रुटि.
410
EN + हिं
GB What is 'stack unwinding'?
IN 'स्टैक अनवाइंडिंग' क्या है?
A
Destructors called for local objects as exception propagates अपवाद प्रसार के रूप में विध्वंसकों ने स्थानीय वस्तुओं को बुलाया
B
Recursive function termination पुनरावर्ती कार्य समाप्ति
C
Stack overflow handling स्टैक ओवरफ्लो प्रबंधन
D
Memory deallocation मेमोरी डिलोकेशन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwinding: as exception propagates, destructors are called for all local objects in the chain of scopes.
व्याख्या (हिन्दी) स्टैक अनवाइंडिंग: जैसे-जैसे अपवाद फैलता है, स्कोप की श्रृंखला में सभी स्थानीय वस्तुओं के लिए डिस्ट्रक्टर्स को बुलाया जाता है।
411
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
A
Oops उफ़
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) E(Oops) thrown and caught by reference. e.msg=Oops. Output: Oops.
व्याख्या (हिन्दी) ई(उफ़) संदर्भ द्वारा फेंका और पकड़ा गया। e.msg=उफ़. आउटपुट: उफ़.
412
EN + हिं
GB What is the output: try{throw 1;}catch(int& i){i=99; cout<
IN आउटपुट क्या है: Try{throw 1;}catch(int& i){i=99; अदालत
A
99 99
B
1 1
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) catch by reference; modify i=99; print i=99. Output: 99.
व्याख्या (हिन्दी) संदर्भ द्वारा पकड़ें; संशोधित करें i=99; i=99 प्रिंट करें। आउटपुट: 99.
413
EN + हिं
GB What is 'exception specification' in C++?
IN C++ में 'अपवाद विशिष्टता' क्या है?
A
noexcept or noexcept(expr) declaring function won't throw noexcept या noexcept(expr) घोषित करने वाला फ़ंक्शन नहीं फेंकेगा
B
throw() specification (deprecated) फेंक() विशिष्टता (अप्रत्याशित)
C
Try-catch inside function फ़ंक्शन के अंदर पकड़ने का प्रयास करें
D
Exception class hierarchy अपवाद वर्ग पदानुक्रम
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) noexcept specifier (C++11) declares a function doesn't throw; violations call terminate().
व्याख्या (हिन्दी) noexcept विनिर्देशक (C++11) घोषित करता है कि कोई फ़ंक्शन फेंकता नहीं है; उल्लंघन कॉल समाप्त()।
414
EN + हिं
GB What is the output: auto f=[]()noexcept{throw 1;}; try{f();}catch(...){cout<<'C';}
IN आउटपुट क्या है: auto f=[]()noexcept{throw 1;}; प्रयास करें{f();}पकड़ो(...){cout
A
C सी
B
std::terminate called std::समाप्त बुलाया गया
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) noexcept function throwing calls std::terminate, not caught by catch.
व्याख्या (हिन्दी) noexcept फ़ंक्शन थ्रोइंग कॉल std::समाप्त, कैच द्वारा नहीं पकड़ा गया।
415
EN + हिं
GB What is 'std::exception_ptr'?
IN 'std::exception_ptr' क्या है?
A
Pointer-like type that can store and rethrow exceptions पॉइंटर जैसा प्रकार जो अपवादों को संग्रहीत और पुनर्स्थापित कर सकता है
B
Base class for all exceptions सभी अपवादों के लिए बेस क्लास
C
Exception handling overhead ओवरहेड अपवाद हैंडलिंग
D
Stack pointer during exception अपवाद के दौरान स्टैक सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::exception_ptr enables storing and rethrowing exceptions across threads or callbacks.
व्याख्या (हिन्दी) std::exception_ptr थ्रेड या कॉलबैक में अपवादों को संग्रहीत करने और पुनर्स्थापित करने में सक्षम बनाता है।
416
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
A
R आर
B
A
C
std::terminate एसटीडी::समाप्त
D
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++ अपवाद नहीं फेंकता - यह संभावित रूप से क्रैश/सिग्नल का कारण बनता है।
417
EN + हिं
GB What is the output: try{throw 1;}catch(long l){cout<<'L';}catch(int i){cout<<'I';}
IN आउटपुट क्या है: प्रयास करें {थ्रो 1;} कैच (लॉन्ग एल) {काउट
A
L एल
B
I मैं
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) No implicit conversion in exception catching; int matches catch(int) not catch(long). Output: I.
व्याख्या (हिन्दी) अपवाद पकड़ने में कोई अंतर्निहित रूपांतरण नहीं; int कैच (int) से मेल खाता है, कैच (लंबा) से नहीं। आउटपुट: मैं.
418
EN + हिं
GB What is 'RETHROW' in C++?
IN C++ में 'रेथ्रो' क्या है?
A
throw; inside catch block re-throws current exception फेंक; कैच ब्लॉक के अंदर वर्तमान अपवाद को फिर से फेंकता है
B
throw exception from catch कैच से अपवाद फेंकें
C
Copy of exception thrown अपवाद की प्रतिलिपि फेंकी गई
D
New exception from catch पकड़ से नया अपवाद
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; (no argument) inside a catch handler rethrows the current exception preserving its type.
व्याख्या (हिन्दी) फेंक; (कोई तर्क नहीं) कैच हैंडलर के अंदर वर्तमान अपवाद को उसके प्रकार को संरक्षित करते हुए पुनर्स्थापित करता है।
419
EN + हिं
GB What is the output: struct Base{virtual ~Base()=default;}; struct Der:Base{}; try{throw Der();}catch(Base& b){cout<<'B';}catch(Der& d){cout<<'D';}
IN आउटपुट क्या है: struct Base{virtual ~Base()=default;}; संरचना डेर:बेस{}; प्रयास करें{थ्रो डेर();}कैच(बेस& बी){काउट
A
B बी
B
D डी
C
Compile error संकलन त्रुटि
D
BD बी.डी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Catch handlers tried in order. Der is-a Base, so catch(Base&) matches first. Output: B. (Put more specific catch first!)
व्याख्या (हिन्दी) कैच संचालकों ने क्रम में प्रयास किया। डेर एक बेस है, इसलिए कैच(बेस&) पहले मेल खाता है। आउटपुट: बी. (पहले अधिक विशिष्ट कैच डालें!)
420
EN + हिं
GB What is 'std::terminate' called in situations besides uncaught exception?
IN अज्ञात अपवाद के अलावा अन्य स्थितियों में 'std::terminet' को क्या कहा जाता है?
A
noexcept function throws, or exception in destructor during unwinding अनवाइंडिंग के दौरान नोएक्सेप्ट फ़ंक्शन थ्रो, या डिस्ट्रक्टर में अपवाद
B
Out of memory स्मृति से बाहर
C
Stack overflow स्टैक ओवरफ़्लो
D
Null pointer dereference शून्य सूचक डीरेफ़रेंस
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::terminate is called: uncaught exception, noexcept violation, exception during stack unwinding, bad terminate() etc.
व्याख्या (हिन्दी) एसटीडी::टर्मिनेट को कहा जाता है: अनकहा अपवाद, नोएक्सेप्ट उल्लंघन, स्टैक अनवाइंडिंग के दौरान अपवाद, खराब टर्मिनेट() आदि।
406–420 of 1915