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

Question 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
B बी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw bad_alloc(); caught. Output: B.
व्याख्या (हिन्दी) Bad_alloc() फेंकें; पकड़ा गया। आउटपुट: बी.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 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
10 10
Compile error संकलन त्रुटि
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.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 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
23 23
26 26
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f catches 1, prints 2, rethrows 3. Outer: prints 3. Output: 23.
व्याख्या (हिन्दी) f कैच 1, प्रिंट 2, रीथ्रो 3. बाहरी: प्रिंट 3. आउटपुट: 23.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1879

EN + हिं
GB What is the output: try{throw;}catch(...){cout<<'C';}
IN आउटपुट क्या है: प्रयास करें {फेंकें;} पकड़ें (...) {काउट करें
terminate बर्खास्त
C सी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::terminate called.
व्याख्या (हिन्दी) std::समाप्त बुलाया गया।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1880

EN + हिं
GB What is the output: class A{public:A(){} ~A()noexcept{cout<<'X';}}; void f(){A a;return;} f(); cout<<'Y';
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {} ~ ए() नोएक्सेप्ट {काउट
XY XY
YX YX
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ~A called on return: X. Then Y. Output: XY.
व्याख्या (हिन्दी) ~ए को वापसी पर बुलाया गया: एक्स। फिर वाई। आउटपुट: एक्सवाई।
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 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) {थ्रो स्ट्रिंग ("इर्रर"));
err ग़लती होना
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner catches int, throws string. Outer catches string. Output: err.
व्याख्या (हिन्दी) इनर कैच इंट, थ्रो स्ट्रिंग। बाहरी कैच स्ट्रिंग. आउटपुट: ग़लती।
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 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
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 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();} कॉउट
10 10
11 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3 found=1; 9 not found=0. Output: 10.
व्याख्या (हिन्दी) 3 पाया=1; 9 नहीं मिला=0. आउटपुट: 10.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 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];} कोउट
4 4
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,3,4,5,8. Middle=4. Output: 4.
व्याख्या (हिन्दी) क्रमबद्ध: 1,3,4,5,8. मध्य=4. आउटपुट: 4.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 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; अदालत
4 4
6 6
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+3=4. Output: 4.
व्याख्या (हिन्दी) 1+3=4. आउटपुट: 4.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 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
12 12
6 6
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(24,36)=12. Output: 12.
व्याख्या (हिन्दी) जीसीडी(24,36)=12. आउटपुट: 12.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 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
1-2-3 1-2-3
123 123
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Join with '-': 1-2-3. Output: 1-2-3.
व्याख्या (हिन्दी) '-' से जुड़ें: 1-2-3. आउटपुट: 1-2-3.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1888

EN + हिं
GB What is the output: template constexpr int fib=N<2?N:fib+fib; cout<;
IN आउटपुट क्या है: टेम्पलेट constexpr int fib=N
55 55
34 34
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fib(10)=55. Output: 55.
व्याख्या (हिन्दी) फ़िब(10)=55. आउटपुट: 55.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 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); अदालत
53 53
35 35
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=5, val=3. Output: 53.
व्याख्या (हिन्दी) आकार=5, वैल=3. आउटपुट: 53.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 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
32 32
15 15
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*4+2*5+3*6=32. Output: 32.
व्याख्या (हिन्दी) 1*4+2*5+3*6=32. आउटपुट: 32.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।