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
16
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) से मेल खाता है, कैच (लंबा) से नहीं। आउटपुट: मैं.
17
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.
व्याख्या (हिन्दी) फेंक; (कोई तर्क नहीं) कैच हैंडलर के अंदर वर्तमान अपवाद को उसके प्रकार को संरक्षित करते हुए पुनर्स्थापित करता है।
18
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!)
व्याख्या (हिन्दी) कैच संचालकों ने क्रम में प्रयास किया। डेर एक बेस है, इसलिए कैच(बेस&) पहले मेल खाता है। आउटपुट: बी. (पहले अधिक विशिष्ट कैच डालें!)
19
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.
व्याख्या (हिन्दी) एसटीडी::टर्मिनेट को कहा जाता है: अनकहा अपवाद, नोएक्सेप्ट उल्लंघन, स्टैक अनवाइंडिंग के दौरान अपवाद, खराब टर्मिनेट() आदि।
20
EN + हिं
GB What is the output: try{throw;}catch(...){cout<<'X';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (...) {काउट करें
A
X एक्स
B
std::terminate एसटीडी::समाप्त
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Re-throw with no active exception calls std::terminate.
व्याख्या (हिन्दी) बिना किसी सक्रिय अपवाद के पुनः थ्रो करें कॉल std::समाप्त करें।
21
EN + हिं
GB What is the output: try{try{throw 1;}catch(int i){throw i+1;}}catch(int i){cout<
IN आउटपुट क्या है: प्रयास करें {कोशिश करें 1 फेंकें;} पकड़ें (int i) {फेंकें i + 1;
A
2 2
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner catch catches 1, throws i+1=2. Outer catch catches 2. Output: 2.
व्याख्या (हिन्दी) इनर कैच कैच 1, थ्रो i+1=2. बाहरी कैच कैच 2. आउटपुट: 2.
22
EN + हिं
GB What is 'function-try-block'?
IN 'फ़ंक्शन-ट्राई-ब्लॉक' क्या है?
A
Try-catch wrapping entire function including member initializer list सदस्य इनिशियलाइज़र सूची सहित संपूर्ण फ़ंक्शन को रैप करने का प्रयास करें
B
Exception in function body only केवल फ़ंक्शन बॉडी में अपवाद
C
A macro for try-catch प्रयास-पकड़ने के लिए एक मैक्रो
D
Template exception handling टेम्प्लेट अपवाद प्रबंधन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Function-try-block: A()try:x(init()){}catch(...){} — catches exceptions in member initializer list.
व्याख्या (हिन्दी) फ़ंक्शन-ट्राई-ब्लॉक: A()try:x(init()){}catch(...){} - सदस्य इनिशियलाइज़र सूची में अपवादों को पकड़ता है।
23
EN + हिं
GB What is the output: void f() noexcept(false){throw 1;} void g() noexcept{f();} try{g();}catch(...){cout<<'C';}
IN आउटपुट क्या है: void f() noexcept(false){throw 1;} void g() noexcept{f();} Try{g();}catch(...){cout
A
C सी
B
std::terminate एसटीडी::समाप्त
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g() is noexcept; when f() throws, the exception escapes g(), triggering terminate().
व्याख्या (हिन्दी) g() कोई अपवाद नहीं है; जब f() फेंकता है, तो अपवाद g() से बच जाता है, जिससे समाप्ति() ट्रिगर हो जाती है।
24
EN + हिं
GB What is the output: try{throw std::runtime_error("fail");}catch(std::exception& e){cout<
IN आउटपुट क्या है: प्रयास करें{थ्रो std::runtime_error('fail');}catch(std::exception& e){cout
A
fail असफल
B
runtime_error रनटाइम त्रुटि
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::runtime_error inherits std::exception. what() returns the message "fail". Output: fail.
व्याख्या (हिन्दी) std::runtime_error को std::अपवाद विरासत में मिला है। क्या() संदेश "विफल" लौटाता है। आउटपुट: असफल.
25
EN + हिं
GB What is 'exception neutral' code?
IN 'अपवाद तटस्थ' कोड क्या है?
A
Code that doesn't catch exceptions but allows them to propagate कोड जो अपवादों को नहीं पकड़ता बल्कि उन्हें प्रचारित करने की अनुमति देता है
B
Code with no exceptions possible बिना किसी अपवाद के कोड संभव है
C
noexcept everywhere हर जगह छोड़कर नहीं
D
Try-catch everywhere हर जगह पकड़ने की कोशिश करो
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Exception neutral code lets exceptions pass through transparently, maintaining strong safety guarantee.
व्याख्या (हिन्दी) अपवाद तटस्थ कोड मजबूत सुरक्षा गारंटी बनाए रखते हुए अपवादों को पारदर्शी रूप से पारित करने देता है।
26
EN + हिं
GB What is the output: struct A{A(){throw 1;} ~A(){cout<<'D';}}; try{A a;}catch(int){cout<<'C';}
IN आउटपुट क्या है: struct A{A(){throw 1;} ~A(){cout
A
DC डीसी
B
CD सीडी
C
C सी
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Object not fully constructed; destructor NOT called. Only catch runs. Output: C.
व्याख्या (हिन्दी) वस्तु पूर्णतः निर्मित नहीं है; विध्वंसक को नहीं बुलाया गया। केवल रन पकड़ो. आउटपुट: सी.
27
EN + हिं
GB What is 'nested exception' in C++?
IN C++ में 'नेस्टेड अपवाद' क्या है?
A
std::nested_exception stores current exception while throwing another std::nested_exception किसी अन्य को फेंकते समय वर्तमान अपवाद को संग्रहीत करता है
B
Exception inside destructor विध्वंसक के अंदर अपवाद
C
Recursive exception पुनरावर्ती अपवाद
D
Exception chain अपवाद शृंखला
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::nested_exception and std::throw_with_nested() allow chaining exceptions (like Java's cause).
व्याख्या (हिन्दी) std::nested_exception और std::throw_with_nested() चेनिंग अपवादों की अनुमति देते हैं (जैसे जावा का कारण)।
28
EN + हिं
GB What is the output: try{vector v; v.at(5);}catch(out_of_range& e){cout<<'O';}catch(...){cout<<'X';}
IN आउटपुट क्या है: प्रयास करें {वेक्टर v; v.at(5);}catch(out_of_range& e){cout
A
O हे
B
X एक्स
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) vector::at() throws std::out_of_range for invalid index. catch(out_of_range) matches. Output: O.
व्याख्या (हिन्दी) वेक्टर::at() अमान्य अनुक्रमणिका के लिए std::out_of_range फेंकता है। कैच(आउट_ऑफ_रेंज) मैच। आउटपुट: ओ.
29
EN + हिं
GB What is the output: int x=0; try{x=1; throw 1; x=2;}catch(int){x=3;} cout<
IN आउटपुट क्या है: int x=0; प्रयास करें{x=1; फेंको 1; x=2;}catch(int){x=3;} cout
A
3 3
B
1 1
C
2 2
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1, throw 1 skips x=2, catch sets x=3. Output: 3.
व्याख्या (हिन्दी) x=1, 1 स्किप x=2 फेंकें, कैच सेट x=3। आउटपुट: 3.
30
EN + हिं
GB What is the output: try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: Try{throw 1;}catch(int i){cout
A
1 1
B
2 2
C
12 12
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Multiple handlers for the same type after the first is unreachable; some compilers warn/error. This is a compile error.
व्याख्या (हिन्दी) पहले के पहुंच से बाहर होने के बाद एक ही प्रकार के लिए एकाधिक हैंडलर; कुछ कंपाइलर्स चेतावनी/त्रुटि देते हैं। यह एक संकलन त्रुटि है.
16–30 of 123