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 1816

EN + हिं
GB What is the output: class A{mapm; public:int& at(const string& k){return m[k];} int get(const string& k)const{auto it=m.find(k);return it!=m.end()?it->second:0;}}; A a; a.at("x")=5; cout<
IN आउटपुट क्या है: class A{mapm; public:int& at(const string& k){return m[k];} int get(const string& k)const{auto it=m.find(k);return it!=m.end()?it-> सेकेंड:0;}}; ए ए; a.at("x")=5; अदालत
50 50
55 55
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=5, y not found=0. Output: 50.
व्याख्या (हिन्दी) x=5, y नहीं मिला=0. आउटपुट: 50.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1817

EN + हिं
GB What is the output: class A{int x=0; public:A& operator+=(const A& o){x+=o.x;return *this;} int get()const{return x;} A(int v=0):x(v){}}; A a(3),b(4); a+=b; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:A& ऑपरेटर+=(const A& o){x+=o.x;return *this;} int get()const{return x;} A(int v=0):x(v){}}; ए ए(3),बी(4); ए+=बी; अदालत
74 74
77 77
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=3+4=7; b.x=4 unchanged. Output: 74.
व्याख्या (हिन्दी) a.x=3+4=7; b.x=4 अपरिवर्तित. आउटपुट: 74.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1818

EN + हिं
GB What is the output: class A{int x=0; public:operator bool()const{return x!=0;} void set(int v){x=v;}}; A a; cout<<(bool)a; a.set(5); cout<<(bool)a;
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: ऑपरेटर बूल() स्थिरांक {वापसी x! = 0;} शून्य सेट (int v) {x = v;}}; ए ए; अदालत
01 01
00 00
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=0: false=0; x=5: true=1. Output: 01.
व्याख्या (हिन्दी) x=0: गलत=0; x=5: सत्य=1. आउटपुट: 01.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1819

EN + हिं
GB What is the output: class A{int x; public:A(int v):x(v){} A operator%(const A& o)const{return {x%o.x};} int get()const{return x;}}; A a(10),b(3); cout<<(a%b).get();
IN आउटपुट क्या है: class A{int x; सार्वजनिक:ए(int v):x(v){} A ऑपरेटर%(const A& o)const{return {x%o.x};} int get()const{return x;}}; ए ए(10),बी(3); अदालत
1 1
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10%3=1. Output: 1.
व्याख्या (हिन्दी) 10%3=1. आउटपुट: 1.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1820

EN + हिं
GB What is the output: class A{int v=0; public:int peek()const{return v;} void push(int x){v=x;} int pop(){int t=v;v=0;return t;}}; A a; a.push(42); cout<
IN आउटपुट क्या है: class A{int v=0; सार्वजनिक:int peek()const{रिटर्न v;} void पुश(int x){v=x;} int पॉप(){int t=v;v=0;रिटर्न t;}}; ए ए; ए.पुश(42); अदालत
420 420
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) pop returns 42, v=0. peek=0. Output: 420.
व्याख्या (हिन्दी) पॉप रिटर्न 42, वी=0। झाँकना=0. आउटपुट: 420.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1821

EN + हिं
GB What is the output: class A{int x; public:A(int v):x(v){} A twice()const{return {x*2};} A inc()const{return {x+1};} int get()const{return x;}}; A a(3); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक:ए(int v):x(v){} A twos()const{return {x*2};} A inc()const{return {x+1};} int get()const{return x;}}; ए ए(3); अदालत
14 14
12 12
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3*2=6; 6+1=7; 7*2=14. Output: 14.
व्याख्या (हिन्दी) 3*2=6; 6+1=7; 7*2=14. आउटपुट: 14.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1822

EN + हिं
GB What is the output: class A{int x=0; public:void f(){x+=2;} void g(){f();f();} void h(){g();g();} int get()const{return x;}}; A a; a.h(); cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:void f(){x+=2;} void g(){f();f();} void h(){g();g();} int get()const{return x;}}; ए ए; ए.एच(); अदालत
8 8
4 4
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) h: g,g. g: f,f. Each f: x+=2. 4 calls: x=8. Output: 8.
व्याख्या (हिन्दी) एच: जी, जी. जी: एफ,एफ। प्रत्येक f: x+=2. 4 कॉल: x=8. आउटपुट: 8.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1823

EN + हिं
GB What is the output: class A{public:virtual int calc(int x)const=0;}; class SqA:public A{public:int calc(int x)const override{return x*x;}}; class CuA:public A{public:int calc(int x)const override{return x*x*x;}}; auto eval=[](const A& a,int x){return a.calc(x);}; SqA sq; CuA cu; cout<
IN आउटपुट क्या है: class A{public:virtual int calc(int x)const=0;}; वर्ग SqA:सार्वजनिक A{सार्वजनिक:int calc(int x)const ओवरराइड{रिटर्न x*x;}}; वर्ग CuA: सार्वजनिक A {सार्वजनिक: int calc (int x) स्थिरांक ओवरराइड {वापसी x*x*x;}}; ऑटो eval=[](const A& a,int x){return a.calc(x);}; वर्गA वर्ग; CuA cu; अदालत
927 927
Compile error संकलन त्रुटि
Undefined अपरिभाषित
9 27 9 27
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(3)=9; cu(3)=27. Output: 927.
व्याख्या (हिन्दी) वर्ग(3)=9; घन(3)=27. आउटपुट: 927.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1824

EN + हिं
GB What is the output: template T clampT(T v,T lo,T hi){return vhi?hi:v;} cout<
IN आउटपुट क्या है: टेम्पलेट टी क्लैंपटी(टी वी,टी लो,टी हाय){रिटर्न वीएचआई?हाय:वी;} कॉउट
5010 5010
1510 1510
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5: in range=5; -5: below=0; 15: above=10. Output: 5010.
व्याख्या (हिन्दी) 5: सीमा में=5; -5: नीचे=0; 15: ऊपर=10. आउटपुट: 5010.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1825

EN + हिं
GB What is the output: class Filter{public:virtual bool pass(int x)const=0;}; class Even:public Filter{public:bool pass(int x)const override{return x%2==0;}}; class Pos:public Filter{public:bool pass(int x)const override{return x>0;}}; auto apply=[](vectorv,const Filter& f){vectorr;for(int x:v)if(f.pass(x))r.push_back(x);return r;};Even e; auto r=apply({-2,1,2,3,4},e); cout<
IN आउटपुट क्या है: वर्ग फ़िल्टर{सार्वजनिक:वर्चुअल बूल पास(int x)const=0;}; कक्षा सम:सार्वजनिक फ़िल्टर{सार्वजनिक:बूल पास(int x)const ओवरराइड{रिटर्न x%2==0;}}; वर्ग स्थिति:सार्वजनिक फ़िल्टर{सार्वजनिक:बूल पास(int x)const ओवरराइड{वापसी x>0;}}; स्वत: लागू=[](वेक्टरv,const फ़िल्टर& f){vectorr;for(int x:v)if(f.pass(x))r.push_back(x);रिटर्न r;};सम ई; स्वतः r=लागू करें({-2,1,2,3,4},e); अदालत
3 3
2 2
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Even from {-2,1,2,3,4}: -2,2,4. size=3. Output: 3.
व्याख्या (हिन्दी) {-2,1,2,3,4} से भी: -2,2,4. आकार=3. आउटपुट: 3.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1826

EN + हिं
GB What is the output: template class Box{T v; public:Box(T x):v(x){} T get()const{return v;} Box map(functionf)const{return Box(f(v));}}; Boxb(5); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास बॉक्स{T v; सार्वजनिक: बॉक्स (टी एक्स): वी (एक्स) {} टी गेट() कॉन्स्ट {रिटर्न वी;} बॉक्स मैप (फंक्शनएफ) कॉन्स्ट {रिटर्न बॉक्स (एफ (वी));}}; बॉक्सबी(5); अदालत
11 11
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+1=11. Output: 11.
व्याख्या (हिन्दी) 5*2=10; 10+1=11. आउटपुट: 11.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1827

EN + हिं
GB What is the output: class Expr{public:virtual int eval()const=0; virtual ~Expr()=default;}; class Num:public Expr{int v;public:Num(int x):v(x){} int eval()const override{return v;}}; class Add:public Expr{Expr*l,*r;public:Add(Expr*a,Expr*b):l(a),r(b){} int eval()const override{return l->eval()+r->eval();}}; Expr*e=new Add(new Num(3),new Add(new Num(4),new Num(5))); cout<eval();
IN आउटपुट क्या है: class Expr{public:virtual int eval()const=0; आभासी ~Expr()=डिफ़ॉल्ट;}; वर्ग संख्या:सार्वजनिक व्याख्या{int v;सार्वजनिक:Num(int x):v(x){} int eval()const ओवरराइड{रिटर्न v;}}; वर्ग जोड़ें:सार्वजनिक एक्सपीआर{एक्सपीआर*एल,*आर;सार्वजनिक:जोड़ें(एक्सपीआर*ए,एक्सपीआर*बी):एल(ए),आर(बी){} int eval()const ओवरराइड{रिटर्न l->eval()+r->eval();}}; एक्सप्र*ई=नया जोड़ें(नया नंबर(3),नया जोड़ें(नया नंबर(4),नया नंबर(5))); अदालत
12 12
7 7
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+(4+5)=12. Output: 12.
व्याख्या (हिन्दी) 3+(4+5)=12. आउटपुट: 12.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1828

EN + हिं
GB What is the output: template T fold(vectorv,T init,functionf){for(T x:v)init=f(init,x);return init;} cout<({1,2,3,4,5},0,[](int a,int b){return a+b;})<({1,2,3,4,5},1,[](int a,int b){return a*b;});
IN आउटपुट क्या है: टेम्पलेट T फ़ोल्ड(वेक्टरv,T init,functionf){for(T x:v)init=f(init,x);रिटर्न init;} cout
15120 15120
Compile error संकलन त्रुटि
Undefined अपरिभाषित
15 120 15 120
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15; Product=120. Output: 15120.
व्याख्या (हिन्दी) योग=15; उत्पाद=120. आउटपुट: 15120.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1829

EN + हिं
GB What is the output: class Predicate{public:virtual bool operator()(int x)const=0;}; class GT{int t; public:GT(int v):t(v){} bool operator()(int x)const{return x>t;}}; auto count=[](vectorv,functionp){return count_if(v.begin(),v.end(),p);}; GT g(3); cout<
IN आउटपुट क्या है: क्लास प्रेडिकेट{पब्लिक:वर्चुअल बूल ऑपरेटर()(int x)const=0;}; क्लास जीटी{इंट टी; सार्वजनिक:GT(int v):t(v){} bool ऑपरेटर()(int x)const{return x>t;}}; ऑटो काउंट=[](वेक्टरv,फंक्शनपी){रिटर्न काउंट_आईएफ(v.begin(),v.end(),p);}; जीटी जी(3); अदालत
2 2
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4 and 5 are >3. count=2. Output: 2.
व्याख्या (हिन्दी) 4 और 5 >3 हैं। गिनती=2. आउटपुट: 2.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1830

EN + हिं
GB What is the output: template vector mapV(vectorv,F f){for(T&x:v)x=f(x);return v;} auto r=mapV({1,2,3,4,5},[](int x){return x*x;}); cout<
IN आउटपुट क्या है: टेम्पलेट वेक्टर मैपV(वेक्टरv,F f){for(T&x:v)x=f(x);रिटर्न v;} ऑटो r=mapV({1,2,3,4,5},[](int x){रिटर्न x*x;}); अदालत
9 9
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) r[2]=3^2=9. Output: 9.
व्याख्या (हिन्दी) आर[2]=3^2=9. आउटपुट: 9.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।