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
61
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.
62
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::समाप्त। आउटपुट: समाप्त करें.
63
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.
64
EN + हिं
GB What is the output: try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: Try{throw 1;}catch(int i){cout
A
Compile error संकलन त्रुटि
B
2 2
C
3 3
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Duplicate handler: compile error.
व्याख्या (हिन्दी) डुप्लिकेट हैंडलर: संकलन त्रुटि।
65
EN + हिं
GB What is the output: class A{public:~A(){cout<<'X';}}; void f(){A a;} try{f();}catch(...){} cout<<'Y';
IN आउटपुट क्या है: क्लास ए{पब्लिक:~ए(){काउट
A
XY XY
B
YX YX
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() returns normally: ~A=X. cout Y. Output: XY.
व्याख्या (हिन्दी) f() सामान्य रूप से लौटाता है: ~A=X. कॉउट वाई. आउटपुट: XY.
66
EN + हिं
GB What is the output: try{throw bad_cast();}catch(bad_cast& e){cout<<'B';}catch(exception& e){cout<<'E';}
IN आउटपुट क्या है: Try{throw Bad_cast();}catch( Bad_cast& e){cout
A
B बी
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) bad_cast caught first. Output: B.
व्याख्या (हिन्दी) बैड_कास्ट पहले पकड़ा गया। आउटपुट: बी.
67
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
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1; throw; x=2 skipped; catch: x=3. Output: 3.
व्याख्या (हिन्दी) एक्स=1; फेंक; x=2 छोड़ दिया गया; पकड़ें: x=3. आउटपुट: 3.
68
EN + हिं
GB What is the output: try{throw logic_error("L");}catch(logic_error& e){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो लॉजिक_एरर ("एल");}कैच (लॉजिक_एरर और ई) {काउट
A
L एल
B
logic_error तर्क_त्रुटि
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) what()=L. Output: L.
व्याख्या (हिन्दी) क्या()=एल. आउटपुट: एल.
69
EN + हिं
GB What is the output: auto f=[]()noexcept->int{return 42;}; try{cout<
IN आउटपुट क्या है: auto f=[]()noexcept->int{return 42;}; प्रयास करें {cout
A
42 42
B
X एक्स
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() returns 42 no throw. Output: 42.
व्याख्या (हिन्दी) f() 42 नो थ्रो लौटाता है। आउटपुट: 42.
70
EN + हिं
GB What is the output: try{throw invalid_argument("bad");}catch(exception& e){cout<
IN आउटपुट क्या है: प्रयास करें {अमान्य_argument फेंकें ("खराब");} पकड़ें (अपवाद और ई) {काउट करें
A
bad खराब
B
exception अपवाद
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) invalid_argument->logic_error->exception. what()=bad. Output: bad.
व्याख्या (हिन्दी) अमान्य_तर्क->तर्क_त्रुटि->अपवाद। क्या()=बुरा। आउटपुट: ख़राब.
71
EN + हिं
GB What is the output: struct A{~A(){if(uncaught_exceptions()>0)cout<<'U'; else cout<<'N';}}; try{A a;throw 1;}catch(int){}
IN आउटपुट क्या है: struct A{~A(){if(uncaught_exceptions()>0)cout
A
U यू
B
N एन
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) During stack unwind ~A: uncaught_exceptions()>0. Output: U.
व्याख्या (हिन्दी) स्टैक के दौरान अनइंड करें ~A: uncaught_exceptions()>0। आउटपुट: यू.
72
EN + हिं
GB What is the output: try{throw 1;}catch(long l){cout<<'L';}catch(int i){cout<<'I';}
IN आउटपुट क्या है: प्रयास करें {थ्रो 1;} कैच (लॉन्ग एल) {काउट
A
I मैं
B
L एल
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Catch matching is exact (no promotion): int matches catch(int). Output: I.
व्याख्या (हिन्दी) कैच मिलान सटीक है (कोई प्रचार नहीं): इंट कैच (इंट) से मेल खाता है। आउटपुट: मैं.
73
EN + हिं
GB What is the output: try{int x=stoi("abc");}catch(invalid_argument&){cout<<'I';}catch(exception&){cout<<'E';}
IN आउटपुट क्या है: Try{int x=stoi("abc");}catch(invalid_argument&){cout
A
I मैं
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) stoi throws invalid_argument. Output: I.
व्याख्या (हिन्दी) Stoi अमान्य_तर्क फेंकता है। आउटपुट: मैं.
74
EN + हिं
GB What is the output: try{cout<<1; throw 1; cout<<2;}catch(int){cout<<3;}cout<<4;
IN आउटपुट क्या है: प्रयास करें{cout
A
134 134
B
1234 1234
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Print 1; throw; skip 2; catch print 3; after try: print 4. Output: 134.
व्याख्या (हिन्दी) प्रिंट 1; फेंक; छोड़ें 2; कैच प्रिंट 3; प्रयास के बाद: प्रिंट 4. आउटपुट: 134.
75
EN + हिं
GB What is the output: struct A{A(){cout<<'C';} ~A(){cout<<'D';}}; try{A a; A b; throw 1;}catch(int){cout<<'E';}
IN आउटपुट क्या है: struct A{A(){cout
A
CCDE सीसीडीई
B
CCEDD सीसीईडीडी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a: C; b: C; throw: ~b=D, ~a=D; catch: E. Output: CCDDE.
व्याख्या (हिन्दी) ए: सी; बी: सी; फेंकें: ~बी=डी, ~ए=डी; कैच: ई. आउटपुट: सीसीडीडीई।
61–75 of 123