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
991
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.
992
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 अपवाद प्राप्त करता है। ई.क्या()=उफ़. आउटपुट: उफ़.
993
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.
994
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 डबल है. पकड़ो(दोगुना)। आउटपुट: डी.
995
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.
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~ए() प्रिंट डी; कैच प्रिंट सी. आउटपुट: डीसी.
996
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 कहा जाता है। आउटपुट: समाप्त करें.
997
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 पकड़ा गया; अदालत
998
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। आउटपुट: ओ.
999
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.
व्याख्या (हिन्दी) वस्तु पूर्णतः निर्मित नहीं है; ~ए नहीं बुलाया गया. कैच प्रिंट सी. आउटपुट: सी.
1000
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.
1001
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() फेंकता नहीं है; कैच दर्ज नहीं किया गया. आउटपुट: वाई.
1002
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 को संशोधित करता है; कोई कोउट नहीं; उत्पादन नही। आउटपुट: (कुछ नहीं)।
1003
EN + हिं
GB What is the output: try{throw;}catch(int){cout<<'I';}catch(...){cout<<'A';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (int) {काउट
A
terminate बर्खास्त
B
A
C
I मैं
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; without active exception: std::terminate. Output: terminate.
व्याख्या (हिन्दी) फेंक; सक्रिय अपवाद के बिना: std::समाप्त। आउटपुट: समाप्त करें.
1004
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
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner catch prints 1, throws 2. But second catch is in same try — no. Outer must catch. Uncaught. terminate. Actually 1 printed then terminate.
व्याख्या (हिन्दी) आंतरिक कैच प्रिंट 1, थ्रो 2। लेकिन दूसरा कैच उसी प्रयास में है - नहीं। बाहरी को पकड़ना होगा. पकड़ में न आया। ख़त्म करो. वास्तव में 1 मुद्रित फिर समाप्त।
1005
EN + हिं
GB What is the output: class E:public exception{public:const char* what()const noexcept override{return "E";}}; try{throw E();}catch(exception& e){cout<
IN आउटपुट क्या है: वर्ग ई:सार्वजनिक अपवाद{सार्वजनिक:स्थिरांक चार* क्या() स्थिरांक noexcept ओवरराइड{वापसी "ई";}}; प्रयास करें{फेंकें E();}पकड़ें(अपवाद& e){cout
A
E
B
exception अपवाद
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.what()="E". Output: E.
व्याख्या (हिन्दी) ई.क्या()='ई'. आउटपुट: ई.
991–1005 of 1915