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
1876
EN + हिं
GB What is the output: try{int* p=nullptr;if(!p)throw bad_alloc();}catch(bad_alloc&){cout<<'B';}
IN आउटपुट क्या है: Try{int* p=nullptr;if(!p)throw Bad_alloc();}catch( Bad_alloc&){cout
A
B बी
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw bad_alloc(); caught. Output: B.
व्याख्या (हिन्दी) Bad_alloc() फेंकें; पकड़ा गया। आउटपुट: बी.
1877
EN + हिं
GB What is the output: int s=0; for(int i=0;i<5;i++){try{if(i%2)throw i;s+=i;}catch(int x){s-=x;}} cout<
IN आउटपुट क्या है: int s=0; for(int i=0;i
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i=0:s+=0=0; i=1:throw,s-=1=-1; i=2:s+=2=1; i=3:throw,s-=3=-2; i=4:s+=4=2. Output: 2.
व्याख्या (हिन्दी) मैं=0:s+=0=0; i=1:फेंकना,s-=1=-1; i=2:s+=2=1; i=3:फेंकना,s-=3=-2; मैं=4:s+=4=2. आउटपुट: 2.
1878
EN + हिं
GB What is the output: void g(){throw 1;} void f(){try{g();}catch(int i){cout<
IN आउटपुट क्या है: void g(){throw 1;} void f(){try{g();}catch(int i){cout
A
23 23
B
26 26
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f catches 1, prints 2, rethrows 3. Outer: prints 3. Output: 23.
व्याख्या (हिन्दी) f कैच 1, प्रिंट 2, रीथ्रो 3. बाहरी: प्रिंट 3. आउटपुट: 23.
1879
EN + हिं
GB What is the output: try{throw;}catch(...){cout<<'C';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (...) {काउट करें
A
terminate बर्खास्त
B
C सी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::terminate called.
व्याख्या (हिन्दी) std::समाप्त बुलाया गया।
1880
EN + हिं
GB What is the output: class A{public:A(){} ~A()noexcept{cout<<'X';}}; void f(){A a;return;} f(); cout<<'Y';
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {} ~ ए() नोएक्सेप्ट {काउट
A
XY XY
B
YX YX
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ~A called on return: X. Then Y. Output: XY.
व्याख्या (हिन्दी) ~ए को वापसी पर बुलाया गया: एक्स। फिर वाई। आउटपुट: एक्सवाई।
1881
EN + हिं
GB What is the output: try{try{throw 1;}catch(int i){throw string("err");}}catch(string& s){cout<
IN आउटपुट क्या है: प्रयास करें {कोशिश करें 1 फेंकें;} पकड़ें (int i) {थ्रो स्ट्रिंग ("इर्रर"));
A
err ग़लती होना
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner catches int, throws string. Outer catches string. Output: err.
व्याख्या (हिन्दी) इनर कैच इंट, थ्रो स्ट्रिंग। बाहरी कैच स्ट्रिंग. आउटपुट: ग़लती।
1882
EN + हिं
GB What is the output: template T sum(T* arr,int n){T s=T{};for(int i=0;i
IN आउटपुट क्या है: टेम्पलेट T sum(T* arr,int n){T s=T{};for(int i=0;i
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
1883
EN + हिं
GB What is the output: template bool contains(vectorv,T x){return find(v.begin(),v.end(),x)!=v.end();} cout<({1,2,3,4,5},3)<({1,2,3},9);
IN आउटपुट क्या है: टेम्प्लेट बूल में शामिल है (वेक्टरv,T x) {रिटर्न फाइंड (v.begin(),v.end(),x)!=v.end();} कॉउट
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3 found=1; 9 not found=0. Output: 10.
व्याख्या (हिन्दी) 3 पाया=1; 9 नहीं मिला=0. आउटपुट: 10.
1884
EN + हिं
GB What is the output: template T median(vectorv){sort(v.begin(),v.end());return v[v.size()/2];} cout<({5,3,8,1,4});
IN आउटपुट क्या है: टेम्पलेट T माध्यिका(वेक्टरv){sort(v.begin(),v.end());रिटर्न v[v.size()/2];} कोउट
A
4 4
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,3,4,5,8. Middle=4. Output: 4.
व्याख्या (हिन्दी) क्रमबद्ध: 1,3,4,5,8. मध्य=4. आउटपुट: 4.
1885
EN + हिं
GB What is the output: template struct Arr{T d[N]; int size(){return N;} T& operator[](int i){return d[i];}}; Arra{}; a[0]=1;a[1]=2;a[2]=3; cout<
IN आउटपुट क्या है: टेम्पलेट संरचना Arr{T d[N]; int आकार(){रिटर्न N;} T& ऑपरेटर[](int i){रिटर्न d[i];}}; आरा{}; a[0]=1;a[1]=2;a[2]=3; अदालत
A
4 4
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+3=4. Output: 4.
व्याख्या (हिन्दी) 1+3=4. आउटपुट: 4.
1886
EN + हिं
GB What is the output: template T gcd2(T a,T b){return b==T{}?a:gcd2(b,a%b);} cout<
IN आउटपुट क्या है: टेम्पलेट T gcd2(T a,T b){return b==T{}?a:gcd2(b,a%b);} cout
A
12 12
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(24,36)=12. Output: 12.
व्याख्या (हिन्दी) जीसीडी(24,36)=12. आउटपुट: 12.
1887
EN + हिं
GB What is the output: template string join(string sep,Args... args){ostringstream oss;bool first=true;((oss<<(first?first=false,string{}:sep)<
IN आउटपुट क्या है: टेम्प्लेट स्ट्रिंग जॉइन(स्ट्रिंग sep,Args...args){ostringstream oss;boolfirst=true;((oss
A
1-2-3 1-2-3
B
123 123
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Join with '-': 1-2-3. Output: 1-2-3.
व्याख्या (हिन्दी) '-' से जुड़ें: 1-2-3. आउटपुट: 1-2-3.
1888
EN + हिं
GB What is the output: template constexpr int fib=N<2?N:fib+fib; cout<;
IN आउटपुट क्या है: टेम्पलेट constexpr int fib=N
A
55 55
B
34 34
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fib(10)=55. Output: 55.
व्याख्या (हिन्दी) फ़िब(10)=55. आउटपुट: 55.
1889
EN + हिं
GB What is the output: template auto makeVector(int n,T val)->vector{return vector(n,val);} auto v=makeVector(5,3); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकवेक्टर(इंट एन,टी वैल)->वेक्टर{रिटर्न वेक्टर(एन,वैल);} ऑटो वी=मेकवेक्टर(5,3); अदालत
A
53 53
B
35 35
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=5, val=3. Output: 53.
व्याख्या (हिन्दी) आकार=5, वैल=3. आउटपुट: 53.
1890
EN + हिं
GB What is the output: template T dotProduct(vectora,vectorb){return inner_product(a.begin(),a.end(),b.begin(),T{});} cout<({1,2,3},{4,5,6});
IN आउटपुट क्या है: टेम्पलेट T dotProduct(vectora,vectorb){return inside_product(a.begin(),a.end(),b.begin(),T{});} cout
A
32 32
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*4+2*5+3*6=32. Output: 32.
व्याख्या (हिन्दी) 1*4+2*5+3*6=32. आउटपुट: 32.
1876–1890 of 1915