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
1861
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 (कोई मिलान नहीं); बाहरी कैच स्ट्रिंग. आउटपुट: आंतरिक.
1862
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.
1863
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 ख़राब.
1864
EN + हिं
GB What is the output: auto divide=[](double a,double b)->expected{if(b==0)return unexpected("zero");return a/b;}; auto r=divide(10,2); cout<<(r?r.value():-1);
IN आउटपुट क्या है: ऑटो डिवाइड = [] (डबल ए, डबल बी) -> अपेक्षित {अगर (बी == 0) अप्रत्याशित वापसी ("शून्य"); रिटर्न ए/बी;}; ऑटो आर=विभाजन(10,2); अदालत
A
5 5
B
-1 -1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b!=0: r=5.0. Output: 5.
व्याख्या (हिन्दी) बी!=0: आर=5.0. आउटपुट: 5.
1865
EN + हिं
GB What is the output: try{throw overflow_error("big");}catch(overflow_error& e){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो ओवरफ्लो_एरर ("बिग");}कैच (ओवरफ्लो_एरर और ई) {काउट
A
big बड़ा
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
overflow_error अतिप्रवाह_त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.what()=big. Output: big.
व्याख्या (हिन्दी) ई.क्या()=बड़ा. आउटपुट: बड़ा.
1866
EN + हिं
GB What is the output: class Ex{public:Ex()=default; Ex(const Ex&){cout<<'C';}}; try{throw Ex();}catch(Ex e){cout<<'E';}
IN आउटपुट क्या है: class Ex{public:Ex()=default; पूर्व(const Ex&){cout
A
CE सीई
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Catch by value: copy ctor=C, then E. Output: CE.
व्याख्या (हिन्दी) मूल्य के आधार पर पकड़ें: ctor=C कॉपी करें, फिर E. आउटपुट: CE।
1867
EN + हिं
GB What is the output: int x=0; auto cleanup=[&x](){x=99;}; try{cleanup(); throw 1;}catch(int){cout<
IN आउटपुट क्या है: int x=0; ऑटो क्लीनअप=[&x](){x=99;}; प्रयास करें{सफाई(); फेंको 1;}पकड़ो(int){cout
A
99 99
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) cleanup sets x=99 before throw. catch: cout<<99. Output: 99.
व्याख्या (हिन्दी) फेंकने से पहले क्लीनअप सेट x=99। पकड़ो: कोउट
1868
EN + हिं
GB What is the output: try{throw vector{1,2,3};}catch(vector& v){cout<
IN आउटपुट क्या है: प्रयास करें {वेक्टर फेंकें {1,2,3};} पकड़ें (वेक्टर और वी) {काउट करें
A
32 32
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=3, v[1]=2. Output: 32.
व्याख्या (हिन्दी) आकार=3, वी[1]=2. आउटपुट: 32.
1869
EN + हिं
GB What is the output: void f(int x){if(x<0)throw invalid_argument("neg"); cout<
IN आउटपुट क्या है: void f(int x){if(x
A
5neg 5नकारात्मक
B
5-1 5-1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(5)=5; f(-1) throws. Output: 5neg.
व्याख्या (हिन्दी) एफ(5)=5; f(-1) फेंकता है। आउटपुट: 5 नकारात्मक.
1870
EN + हिं
GB What is the output: int x=0; try{x=1;throw;} catch(...){}
IN आउटपुट क्या है: int x=0; प्रयास करें{x=1;फेंकें;} पकड़ें(...){}
A
std::terminate एसटीडी::समाप्त
B
1 1
C
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw; with no active exception: std::terminate.
व्याख्या (हिन्दी) फेंक; बिना किसी सक्रिय अपवाद के: std::समाप्त।
1871
EN + हिं
GB What is the output: struct A{A(){cout<<'A';} ~A(){cout<<'a';}}; struct B{B(){cout<<'B';} ~B(){cout<<'b';}}; try{A a;B b;throw 1;}catch(int){cout<<'E';}
IN आउटपुट क्या है: struct A{A(){cout
A
ABbaE एबीबीएई
B
ABabE ए.बी.ए.बी.ई
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A,B ctors; throw: ~B(b),~A(a); catch: E. Output: ABbaE.
व्याख्या (हिन्दी) ए, बी ctors; फेंकें: ~बी(बी),~ए(ए); कैच: ई. आउटपुट: एबीबीएई।
1872
EN + हिं
GB What is the output: auto f=[]()->pair{try{throw runtime_error("oops");return{true,""};}catch(exception&e){return{false,e.what()};}}; auto [ok,msg]=f(); cout<
IN आउटपुट क्या है: auto f=[]()->pair{try{throw runtime_error("उफ़");रिटर्न{true,""};}कैच(अपवाद&e){रिटर्न{false,e.what()};}}; ऑटो [ठीक है, संदेश]=f(); अदालत
A
0oops 0उफ़
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ok=0,msg=oops. Output: 0oops.
व्याख्या (हिन्दी) ठीक=0, संदेश=उफ़। आउटपुट: 0उफ़.
1873
EN + हिं
GB What is the output: int n=0; try{while(true){n++;if(n>3)throw n;}}catch(int x){cout<
IN आउटपुट क्या है: int n=0; प्रयास करें {जबकि (सही) {n ++; यदि (n> 3) फेंकें n;}} पकड़ें (int x) {cout
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) n=4>3: throw 4. Output: 4.
व्याख्या (हिन्दी) n=4>3: थ्रो 4. आउटपुट: 4.
1874
EN + हिं
GB What is the output: try{throw 3.14;}catch(double d){cout<
IN आउटपुट क्या है: प्रयास करें {थ्रो 3.14;} कैच (डबल डी) {काउट
A
3.14 3.14
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
3 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Exact match: catch(double). Output: 3.14.
व्याख्या (हिन्दी) सटीक मिलान: पकड़ें(डबल)। आउटपुट: 3.14.
1875
EN + हिं
GB What is the output: class E{int c;public:E(int v):c(v){} int code(){return c;}}; try{throw E(7);}catch(E e){cout<
IN आउटपुट क्या है: क्लास E{int c;public:E(int v):c(v){} int कोड(){रिटर्न c;}}; प्रयास करें{फेंकें E(7);}पकड़ें(E e){cout
A
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) e.code()=7. Output: 7.
व्याख्या (हिन्दी) ई.कोड()=7. आउटपुट: 7.
1861–1875 of 1915