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
46
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::समाप्त। आउटपुट: समाप्त करें.
47
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 मुद्रित फिर समाप्त।
48
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.
व्याख्या (हिन्दी) ई.क्या()='ई'. आउटपुट: ई.
49
EN + हिं
GB What is the output: try{new int[1000000000000];}catch(bad_alloc& e){cout<<'M';}
IN आउटपुट क्या है: Try{new int[1000000000000];}catch( Bad_alloc& e){cout
A
M एम
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Crash टकरा जाना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) new throws bad_alloc on failure. Output: M.
व्याख्या (हिन्दी) विफलता पर new Bad_alloc फेंकता है। आउटपुट: एम.
50
EN + हिं
GB What is the output: try{throw 1;}catch(int i){throw i+1;}catch(int i){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो 1;} कैच (इंट आई) {थ्रो आई + 1;} कैच (इंट आई) {काउट
A
terminate बर्खास्त
B
2 2
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw i+1 from catch re-throws out of the try-catch; second catch not executed. Uncaught: terminate.
व्याख्या (हिन्दी) i+1 को कैच से थ्रो करें, ट्राई-कैच से पुनः थ्रो करें; दूसरा कैच निष्पादित नहीं हुआ. पकड़ में न आया: समाप्त करें।
51
EN + हिं
GB What is the output: int a=0; try{a=1;}finally{a=2;}
IN आउटपुट क्या है: int a=0; प्रयास करें{a=1;}आख़िरकार{a=2;}
A
Compile error संकलन त्रुटि
B
2 2
C
1 1
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++ has no finally keyword. Compile error.
व्याख्या (हिन्दी) C++ में अंततः कोई कीवर्ड नहीं है। संकलन त्रुटि.
52
EN + हिं
GB What is the output: try{int*p=nullptr; delete p;}catch(...){cout<<'X';} cout<<'Y';
IN आउटपुट क्या है: Try{int*p=nullptr; हटाएँ p;}पकड़ो(...){cout
A
Y वाई
B
XY XY
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) delete nullptr is no-op; no exception. Output: Y.
व्याख्या (हिन्दी) nullptr को हटाना कोई विकल्प नहीं है; कोई अपवाद नहीं. आउटपुट: वाई.
53
EN + हिं
GB What is the output: struct Guard{~Guard(){cout<<'G';}}; auto f=[](){Guard g; throw 1;}; try{f();}catch(int){cout<<'C';}
IN आउटपुट क्या है: स्ट्रक्चर गार्ड{~गार्ड(){काउट
A
GC जीसी
B
CG तटरक्षक
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwind: ~Guard=G; catch: C. Output: GC.
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~गार्ड=जी; कैच: सी. आउटपुट: जीसी.
54
EN + हिं
GB What is the output: try{throw 1.0f;}catch(float f){cout<<'F';}catch(double d){cout<<'D';}
IN आउटपुट क्या है: प्रयास करें {थ्रो 1.0 एफ;} कैच (फ्लोट एफ) {काउट
A
F एफ
B
D डी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1.0f is float. catch(float). Output: F.
व्याख्या (हिन्दी) 1.0f फ्लोट है. पकड़ना(तैरना)। आउटपुट: एफ.
55
EN + हिं
GB What is the output: int x=0; try{throw 1;}catch(int i){x=i;} cout<
IN आउटपुट क्या है: int x=0; प्रयास करें{थ्रो 1;}कैच(int i){x=i;} कोउट
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=i=1. Output: 1.
व्याख्या (हिन्दी) एक्स=मैं=1. आउटपुट: 1.
56
EN + हिं
GB What is the output: try{throw exception();}catch(exception& e){cout<
IN आउटपुट क्या है: प्रयास करें {अपवाद फेंकें();} पकड़ें (अपवाद और ई) {काउट
A
std::exception एसटीडी::अपवाद
B
exception अपवाद
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Base exception what() returns implementation-defined message, typically "std::exception".
व्याख्या (हिन्दी) आधार अपवाद क्या() कार्यान्वयन-परिभाषित संदेश लौटाता है, आमतौर पर "std::exception"।
57
EN + हिं
GB What is the output: class A{public:A(){cout<<'A';} ~A(){cout<<'a';}}; class B{public:B(){cout<<'B';throw 1;} ~B(){cout<<'b';}}; try{A a;B b;}catch(int){cout<<'C';}
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
ABaC एबीएसी
B
ABC एबीसी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A=A; B ctor starts=B, throws; B not fully constructed: ~B not called; ~A called=a; catch=C. Output: ABaC.
व्याख्या (हिन्दी) ए=ए; B ctor प्रारंभ=B, फेंकता है; बी पूरी तरह से निर्मित नहीं: ~बी को नहीं बुलाया गया; ~ए बुलाया=ए; पकड़=सी. आउटपुट: एबीएसी।
58
EN + हिं
GB What is the output: try{throw 1;}catch(const int& i){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो 1;} पकड़ें (स्थिरांक int और i) {काउट
A
2 2
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) const int& catches 1. i+1=2. Output: 2.
व्याख्या (हिन्दी) const int& कैच 1. i+1=2. आउटपुट: 2.
59
EN + हिं
GB What is the output: try{throw runtime_error("test");}catch(logic_error&){cout<<'L';}catch(runtime_error&){cout<<'R';}
IN आउटपुट क्या है: Try{throw runtime_error("test");}catch(logic_error&){cout
A
R आर
B
L एल
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) runtime_error doesn't inherit logic_error; second catch matches. Output: R.
व्याख्या (हिन्दी) रनटाइम_एरर को लॉजिक_एरर विरासत में नहीं मिलता; दूसरा कैच मैच. आउटपुट: आर.
60
EN + हिं
GB What is the output: try{try{throw 1;}catch(int i){cout<<'I'; if(i==1)throw;}}catch(int i){cout<<'O';}
IN आउटपुट क्या है: प्रयास करें {कोशिश करें 1 फेंकें;} पकड़ें (int i) {cout
A
IO आईओ
B
I मैं
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner: I; rethrow; outer: O. Output: IO.
व्याख्या (हिन्दी) भीतरी: मैं; पुनः फेंकना; बाहरी: O. आउटपुट: IO.
46–60 of 123