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
31
EN + हिं
GB What is the output: try{throw 5;}catch(int i){cout<
IN आउटपुट क्या है: Try{throw 5;}catch(int i){cout
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Catch int 5. Output: 5.
व्याख्या (हिन्दी) कैच इंट 5. आउटपुट: 5.
32
EN + हिं
GB What is the output: try{throw string("err");}catch(const string& s){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो स्ट्रिंग ("err");} पकड़ें (कॉन्स्ट स्ट्रिंग और एस) {काउट
A
3 3
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) "err".size()=3. Output: 3.
व्याख्या (हिन्दी) "त्रुटि"।आकार()=3। आउटपुट: 3.
33
EN + हिं
GB What is the output: struct E{int code; string msg;}; try{throw E{404,"not found"};}catch(E& e){cout<
IN आउटपुट क्या है: struct E{int कोड; स्ट्रिंग संदेश;}; प्रयास करें{फेंकें E{404,"नहीं मिला"};}पकड़ें(E& e){cout
A
404 404
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.code=404. Output: 404.
व्याख्या (हिन्दी) ई.कोड=404. आउटपुट: 404.
34
EN + हिं
GB What is the output: try{try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: प्रयास करें {कोशिश करें 1 फेंकें;} पकड़ें (int i) {cout
A
11 11
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner prints 1; rethrow; outer prints 1. Output: 11.
व्याख्या (हिन्दी) भीतरी प्रिंट 1; पुनः फेंकना; बाहरी प्रिंट 1. आउटपुट: 11.
35
EN + हिं
GB What is the output: void f(){throw runtime_error("oops");} try{f();}catch(exception& e){cout<
IN आउटपुट क्या है: void f(){throw runtime_error("उफ़");} प्रयास करें{f();}पकड़ें(अपवाद& e){cout
A
oops उफ़
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) runtime_error inherits exception. e.what()=oops. Output: oops.
व्याख्या (हिन्दी) runtime_error अपवाद प्राप्त करता है। ई.क्या()=उफ़. आउटपुट: उफ़.
36
EN + हिं
GB What is the output: int x=0; try{x=1; if(true) throw 'E'; x=2;}catch(char c){cout<
IN आउटपुट क्या है: int x=0; प्रयास करें{x=1; यदि (सही) 'ई' फेंकें; x=2;}पकड़ो(char c){cout
A
E1 ई 1
B
E2 ई2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1, throw 'E', catch: x=1. Output: E1.
व्याख्या (हिन्दी) x=1, 'ई' फेंको, पकड़ो: x=1। आउटपुट: E1.
37
EN + हिं
GB What is the output: try{throw 1.0;}catch(int){cout<<'I';}catch(double){cout<<'D';}catch(...){cout<<'A';}
IN आउटपुट क्या है: प्रयास करें {थ्रो 1.0;} कैच (इंट) {काउट
A
D डी
B
I मैं
C
A
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1.0 is double. catch(double). Output: D.
व्याख्या (हिन्दी) 1.0 डबल है. पकड़ो(दोगुना)। आउटपुट: डी.
38
EN + हिं
GB What is the output: class A{public:~A(){cout<<'D';}}; void f(){A a; throw 1;} try{f();}catch(int){cout<<'C';}
IN आउटपुट क्या है: क्लास ए{पब्लिक:~ए(){काउट
A
DC डीसी
B
CD सीडी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwind: ~A() prints D; catch prints C. Output: DC.
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~ए() प्रिंट डी; कैच प्रिंट सी. आउटपुट: डीसी.
39
EN + हिं
GB What is the output: try{throw;}catch(...){cout<<'X';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (...) {काउट करें
A
std::terminate एसटीडी::समाप्त
B
X एक्स
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; with no active exception: std::terminate called. Output: terminate.
व्याख्या (हिन्दी) फेंक; बिना किसी सक्रिय अपवाद के: std::terminet कहा जाता है। आउटपुट: समाप्त करें.
40
EN + हिं
GB What is the output: auto f=[]()->int{throw 1; return 0;}; try{cout<
IN आउटपुट क्या है: auto f=[]()->int{throw 1; वापसी 0;}; प्रयास करें {cout
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw 1 caught; cout<<1. Output: 1.
व्याख्या (हिन्दी) फेंको 1 पकड़ा गया; अदालत
41
EN + हिं
GB What is the output: try{vectorv; v.at(10);}catch(out_of_range&){cout<<'O';}catch(exception&){cout<<'E';}
IN आउटपुट क्या है: Try{vectorv; v.at(10);}catch(out_of_range&){cout
A
O हे
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) at(10) on empty vector: out_of_range. Output: O.
व्याख्या (हिन्दी) खाली वेक्टर पर (10) पर: out_of_range। आउटपुट: ओ.
42
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
C सी
B
DC डीसी
C
CD सीडी
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Object not fully constructed; ~A not called. Catch prints C. Output: C.
व्याख्या (हिन्दी) वस्तु पूर्णतः निर्मित नहीं है; ~ए नहीं बुलाया गया. कैच प्रिंट सी. आउटपुट: सी.
43
EN + हिं
GB What is the output: int x=0; try{x=1;} catch(...){x=2;} cout<
IN आउटपुट क्या है: int x=0; प्रयास करें{x=1;} पकड़ें(...){x=2;} कोउट करें
A
1 1
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) No exception thrown; x=1. Output: 1.
व्याख्या (हिन्दी) कोई अपवाद नहीं फेंका गया; एक्स=1. आउटपुट: 1.
44
EN + हिं
GB What is the output: void f() noexcept{} try{f();}catch(...){cout<<'X';} cout<<'Y';
IN आउटपुट क्या है: void f() noexcept{} Try{f();}catch(...){cout
A
Y वाई
B
XY XY
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() doesn't throw; catch not entered. Output: Y.
व्याख्या (हिन्दी) f() फेंकता नहीं है; कैच दर्ज नहीं किया गया. आउटपुट: वाई.
45
EN + हिं
GB What is the output: try{throw 1;}catch(int& i){i=99;}
IN आउटपुट क्या है: Try{throw 1;}catch(int& i){i=99;}
A
Nothing कुछ नहीं
B
99 99
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Modifies caught int; no cout; no output. Output: (nothing).
व्याख्या (हिन्दी) पकड़े गए int को संशोधित करता है; कोई कोउट नहीं; उत्पादन नही। आउटपुट: (कुछ नहीं)।
31–45 of 123