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
421
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::समाप्त करें।
422
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.
423
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(...){} - सदस्य इनिशियलाइज़र सूची में अपवादों को पकड़ता है।
424
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() से बच जाता है, जिससे समाप्ति() ट्रिगर हो जाती है।
425
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::अपवाद विरासत में मिला है। क्या() संदेश "विफल" लौटाता है। आउटपुट: असफल.
426
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.
व्याख्या (हिन्दी) अपवाद तटस्थ कोड मजबूत सुरक्षा गारंटी बनाए रखते हुए अपवादों को पारदर्शी रूप से पारित करने देता है।
427
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.
व्याख्या (हिन्दी) वस्तु पूर्णतः निर्मित नहीं है; विध्वंसक को नहीं बुलाया गया। केवल रन पकड़ो. आउटपुट: सी.
428
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() चेनिंग अपवादों की अनुमति देते हैं (जैसे जावा का कारण)।
429
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 फेंकता है। कैच(आउट_ऑफ_रेंज) मैच। आउटपुट: ओ.
430
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.
431
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.
व्याख्या (हिन्दी) पहले के पहुंच से बाहर होने के बाद एक ही प्रकार के लिए एकाधिक हैंडलर; कुछ कंपाइलर्स चेतावनी/त्रुटि देते हैं। यह एक संकलन त्रुटि है.
432
EN + हिं
GB What is the output: template T add(T a,T b){return a+b;} cout<
IN आउटपुट क्या है: टेम्प्लेट टी ऐड(टी ए,टी बी){रिटर्न ए+बी;} कॉउट
A
7 4 7 4
B
7 4.0 7 4.0
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) add(3,4)=7, add(1.5,2.5)=4.0. Output: 7 4.
व्याख्या (हिन्दी) जोड़(3,4)=7, जोड़(1.5,2.5)=4.0। आउटपुट: 7 4.
433
EN + हिं
GB What is 'template argument deduction'?
IN 'टेम्पलेट तर्क कटौती' क्या है?
A
Compiler deduces template type from function call arguments कंपाइलर फ़ंक्शन कॉल तर्कों से टेम्पलेट प्रकार का अनुमान लगाता है
B
Specifying template args explicitly टेम्पलेट तर्कों को स्पष्ट रूप से निर्दिष्ट करना
C
Runtime type deduction रनटाइम प्रकार की कटौती
D
SFINAE SFINAE
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Template argument deduction: the compiler infers T from the argument types when calling a function template.
व्याख्या (हिन्दी) टेम्प्लेट तर्क कटौती: फ़ंक्शन टेम्प्लेट को कॉल करते समय कंपाइलर तर्क प्रकारों से टी का अनुमान लगाता है।
434
EN + हिं
GB What is the output: template int f(){return N*N;} cout<();
IN आउटपुट क्या है: टेम्पलेट int f(){return N*N;} cout
A
25 25
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) N=5 at compile time. f<5>()=5*5=25. Output: 25.
व्याख्या (हिन्दी) संकलन समय पर N=5. एफ()=5*5=25. Output: 25.
435
EN + हिं
GB What is 'template specialization'?
IN 'टेम्पलेट विशेषज्ञता' क्या है?
A
Providing specific implementation for particular template argument विशेष टेम्पलेट तर्क के लिए विशिष्ट कार्यान्वयन प्रदान करना
B
Overloading templates टेम्प्लेट ओवरलोड हो रहे हैं
C
Runtime template selection रनटाइम टेम्पलेट चयन
D
Template inheritance टेम्पलेट विरासत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Explicit specialization: template<> void f(){} provides custom implementation for T=int.
व्याख्या (हिन्दी) स्पष्ट विशेषज्ञता: टेम्पलेट void f(){} T=int के लिए कस्टम कार्यान्वयन प्रदान करता है।
421–435 of 1915