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
1006
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 फेंकता है। आउटपुट: एम.
1007
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 को कैच से थ्रो करें, ट्राई-कैच से पुनः थ्रो करें; दूसरा कैच निष्पादित नहीं हुआ. पकड़ में न आया: समाप्त करें।
1008
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++ में अंततः कोई कीवर्ड नहीं है। संकलन त्रुटि.
1009
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 को हटाना कोई विकल्प नहीं है; कोई अपवाद नहीं. आउटपुट: वाई.
1010
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.
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~गार्ड=जी; कैच: सी. आउटपुट: जीसी.
1011
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 फ्लोट है. पकड़ना(तैरना)। आउटपुट: एफ.
1012
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.
1013
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"।
1014
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, फेंकता है; बी पूरी तरह से निर्मित नहीं: ~बी को नहीं बुलाया गया; ~ए बुलाया=ए; पकड़=सी. आउटपुट: एबीएसी।
1015
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.
1016
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.
व्याख्या (हिन्दी) रनटाइम_एरर को लॉजिक_एरर विरासत में नहीं मिलता; दूसरा कैच मैच. आउटपुट: आर.
1017
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.
1018
EN + हिं
GB What is the output: auto safe=[](auto f)->optional{try{return f();}catch(...){return nullopt;}}; auto r=safe([]()->int{throw 1; return 0;}); cout<
IN आउटपुट क्या है: ऑटो सेफ=[](ऑटो एफ)->वैकल्पिक{प्रयास{रिटर्न एफ();}कैच(...){रिटर्न नॉलॉप्ट;}}; ऑटो आर=सुरक्षित([]()->int{थ्रो 1; रिटर्न 0;}); अदालत
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Exception thrown; returns nullopt. has_value()=false=0. Output: 0.
व्याख्या (हिन्दी) अपवाद फेंक दिया गया; शून्य लौटाता है। has_value()=गलत=0. आउटपुट: 0.
1019
EN + हिं
GB What is the output: try{throw 1;}catch(int){throw;}catch(...){cout<<'A';}
IN आउटपुट क्या है: प्रयास करें {थ्रो 1;} कैच (इंट) {थ्रो;} कैच (...) {काउट
A
Propagates (terminate if uncaught) प्रचारित करता है (यदि पकड़ में नहीं आया तो समाप्त करें)
B
A
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; rethrows 1. No outer handler: std::terminate. Output: terminate.
व्याख्या (हिन्दी) फेंक; पुनः फेंकता है 1. कोई बाहरी हैंडलर नहीं: std::समाप्त। आउटपुट: समाप्त करें.
1020
EN + हिं
GB What is the output: struct Ex{int code;}; try{throw Ex{42};}catch(Ex& e){cout<
IN आउटपुट क्या है: struct Ex{int कोड;}; प्रयास करें{फेंकें Ex{42};}पकड़ें(Ex& e){cout
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.code=42. Output: 42.
व्याख्या (हिन्दी) ई.कोड=42. आउटपुट: 42.
1006–1020 of 1915