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
1021
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.
व्याख्या (हिन्दी) डुप्लिकेट हैंडलर: संकलन त्रुटि।
1022
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.
1023
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.
व्याख्या (हिन्दी) बैड_कास्ट पहले पकड़ा गया। आउटपुट: बी.
1024
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.
1025
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.
व्याख्या (हिन्दी) क्या()=एल. आउटपुट: एल.
1026
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.
1027
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.
व्याख्या (हिन्दी) अमान्य_तर्क->तर्क_त्रुटि->अपवाद। क्या()=बुरा। आउटपुट: ख़राब.
1028
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। आउटपुट: यू.
1029
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.
व्याख्या (हिन्दी) कैच मिलान सटीक है (कोई प्रचार नहीं): इंट कैच (इंट) से मेल खाता है। आउटपुट: मैं.
1030
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 अमान्य_तर्क फेंकता है। आउटपुट: मैं.
1031
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.
1032
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.
व्याख्या (हिन्दी) ए: सी; बी: सी; फेंकें: ~बी=डी, ~ए=डी; कैच: ई. आउटपुट: सीसीडीडीई।
1033
EN + हिं
GB What is the output: template T maxOf(T a,T b){return a>b?a:b;} cout<
IN आउटपुट क्या है: टेम्पलेट T maxOf(T a,T b){return a>b?a:b;} cout
A
72.5 72.5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
3 7 3 7
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) maxOf(3,7)=7, maxOf(2.5,1.5)=2.5. Output: 72.5.
व्याख्या (हिन्दी) maxOf(3,7)=7, maxOf(2.5,1.5)=2.5. आउटपुट: 72.5.
1034
EN + हिं
GB What is the output: template struct Pair{T a,b; Pair(T x,T y):a(x),b(y){} T sum(){return a+b;}}; Pair p(3,4); cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर पेयर{T a,b; जोड़ी(टी एक्स,टी वाई):ए(एक्स),बी(वाई){} टी योग(){रिटर्न ए+बी;}}; जोड़ी पी(3,4); अदालत
A
7 7
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+4=7. Output: 7.
व्याख्या (हिन्दी) 3+4=7. आउटपुट: 7.
1035
EN + हिं
GB What is the output: template auto add(T a,U b){return a+b;} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ऐड(टी ए,यू बी){रिटर्न ए+बी;} कॉउट
A
3.5 3.5
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int+double=3.5. Output: 3.5.
व्याख्या (हिन्दी) int+डबल=3.5. आउटपुट: 3.5.
1021–1035 of 1915