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
91
EN + हिं
GB What is the output: try{int x=5,y=0;if(!y)throw domain_error("div0");cout<
IN आउटपुट क्या है: Try{int x=5,y=0;if(!y)throw Domain_error("div0");cout
A
div0 div0
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Throws domain_error. Output: div0.
व्याख्या (हिन्दी) डोमेन_त्रुटि फेंकता है। आउटपुट: div0.
92
EN + हिं
GB What is the output: try{vectorv={1,2,3};cout<
IN आउटपुट क्या है: Try{vectorv={1,2,3};cout
A
O हे
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) at(5) on size-3 vector: out_of_range. Output: O.
व्याख्या (हिन्दी) at(5) आकार-3 वेक्टर पर: out_of_range। आउटपुट: ओ.
93
EN + हिं
GB What is the output: struct A{~A()noexcept{cout<<'D';}}; try{A a;throw 1;}catch(int){cout<<'C';}
IN आउटपुट क्या है: struct A{~A()noexcept{cout
A
DC डीसी
B
CD सीडी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Stack unwind: ~A=D; catch: C. Output: DC.
व्याख्या (हिन्दी) स्टैक अनवाइंड: ~ए=डी; कैच: सी. आउटपुट: डीसी.
94
EN + हिं
GB What is the output: int f()noexcept{return 42;} try{cout<
IN आउटपुट क्या है: int f()noexcept{return 42;} Try{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.
95
EN + हिं
GB What is the output: auto safe=[](auto f,auto... args)->optional{try{return f(args...);}catch(...){return nullopt;}}; auto r=safe([](int x,int y)->int{if(!y)throw 1;return x/y;},10,0); cout<
IN आउटपुट क्या है: ऑटो सेफ=[](ऑटो एफ,ऑटो...आर्ग्स)->वैकल्पिक{प्रयास{रिटर्न एफ(आर्ग्स...);}कैच(...){रिटर्न नॉलॉप्ट;}}; ऑटो आर=सुरक्षित([](int x,int y)->int{if(!y)throw 1;return x/y;},10,0); अदालत
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Throws; returns nullopt. has_value=0. Output: 0.
व्याख्या (हिन्दी) फेंकता है; शून्य लौटाता है। has_value=0. आउटपुट: 0.
96
EN + हिं
GB What is the output: try{string s=string(1,'A'); s.at(5);}catch(out_of_range&){cout<<'O';}
IN आउटपुट क्या है: Try{string s=string(1,'A'); s.at(5);}कैच(out_of_range&){cout
A
O हे
B
A
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) s.at(5) on size-1 string: out_of_range. Output: O.
व्याख्या (हिन्दी) s.at(5) आकार-1 स्ट्रिंग पर: out_of_range। आउटपुट: ओ.
97
EN + हिं
GB What is the output: int n=0; try{for(int i=0;i<5;i++){n++;if(n==3)throw n;}}catch(int x){cout<
IN आउटपुट क्या है: int n=0; प्रयास करें{for(int i=0;i
A
33 33
B
35 35
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Throws when n==3. x=3,n=3. Output: 33.
व्याख्या (हिन्दी) फेंकता है जब n==3. एक्स=3,एन=3. आउटपुट: 33.
98
EN + हिं
GB What is the output: class E:public runtime_error{public:E(string s):runtime_error(s){}}; try{throw E("myerr");}catch(E& e){cout<
IN आउटपुट क्या है: क्लास ई:पब्लिक रनटाइम_एरर{पब्लिक:ई(स्ट्रिंग एस):रनटाइम_एरर(एस){}}; प्रयास करें{फेंकें E("myerr");}पकड़ें(E& e){cout
A
myerr मायर
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.what()=myerr. Output: myerr.
व्याख्या (हिन्दी) e.what()=myerr. आउटपुट: मायर.
99
EN + हिं
GB What is the output: int x=0; try{x=1;try{x=2;throw 1;x=3;}catch(int){x=4;}} cout<
IN आउटपुट क्या है: int x=0; प्रयास करें {x = 1; प्रयास करें {x = 2; फेंकें 1;
A
4 4
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1,2; throw; x=4. Output: 4.
व्याख्या (हिन्दी) एक्स=1,2; फेंक; एक्स=4. आउटपुट: 4.
100
EN + हिं
GB What is the output: void f(){try{throw 1;}catch(int i){cout<
IN आउटपुट क्या है: void f(){try{throw 1;}catch(int i){cout
A
111 111
B
1 11 1 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f: catch prints 1, throws 11. Outer: catches 11. Output: 111.
व्याख्या (हिन्दी) एफ: कैच प्रिंट 1, थ्रो 11. आउटर: कैच 11. आउटपुट: 111.
101
EN + हिं
GB What is the output: try{auto p=make_unique(5); throw *p;}catch(int i){cout<
IN आउटपुट क्या है: Try{auto p=make_unique(5); फेंको *p;}पकड़ो(int i){cout
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw *p throws int 5. Output: 5.
व्याख्या (हिन्दी) थ्रो *पी थ्रो इंट 5. आउटपुट: 5.
102
EN + हिं
GB What is the output: struct Guard{int& r; Guard(int& x):r(x){r=1;} ~Guard(){r=2;}}; int x=0; try{Guard g(x); throw 1;}catch(int){cout<
IN आउटपुट क्या है: structguard{int& r; गार्ड(int& x):r(x){r=1;} ~गार्ड(){r=2;}}; int x=0; कोशिश करें {गार्ड जी (एक्स); फेंको 1;}पकड़ो(int){cout
A
2 2
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ~Guard: r=2. catch: cout<
व्याख्या (हिन्दी) ~गार्ड: r=2. पकड़ो: कोउट
103
EN + हिं
GB What is the output: try{try{throw string("inner");}catch(int){cout<<'I';}}catch(string& s){cout<
IN आउटपुट क्या है: प्रयास करें {कोशिश करें स्ट्रिंग फेंकें ("आंतरिक");} पकड़ें (int) {cout
A
inner आंतरिक
B
I मैं
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) string thrown; inner catches int (no match); outer catches string. Output: inner.
व्याख्या (हिन्दी) तार फेंका गया; आंतरिक कैच int (कोई मिलान नहीं); बाहरी कैच स्ट्रिंग. आउटपुट: आंतरिक.
104
EN + हिं
GB What is the output: int x=5; try{if(x>0)throw x; cout<<'N';}catch(int i){cout<
IN आउटपुट क्या है: int x=5; प्रयास करें{if(x>0)फेंकें x; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw 5; catch: 5*2=10. Output: 10.
व्याख्या (हिन्दी) फेंको 5; पकड़ें: 5*2=10. आउटपुट: 10.
105
EN + हिं
GB What is the output: struct E{int code; string msg;}; try{throw E{42,"bad"};}catch(E& e){cout<
IN आउटपुट क्या है: struct E{int कोड; स्ट्रिंग संदेश;}; प्रयास करें{फेंकें E{42,"खराब"};}पकड़ें(E& e){मुकाबला करें
A
42bad 42खराब
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.code=42, e.msg=bad. Output: 42bad.
व्याख्या (हिन्दी) ई.कोड=42, ई.एमएसजी=खराब। आउटपुट: 42 ख़राब.
91–105 of 123