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
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; अदालत
A
50 50
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=5, y not found=0. Output: 50.
व्याख्या (हिन्दी) x=5, y नहीं मिला=0. आउटपुट: 50.
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); ए+=बी; अदालत
A
74 74
B
77 77
C
Compile error संकलन त्रुटि
D
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.
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;}}; ए ए; अदालत
A
01 01
B
00 00
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=0: false=0; x=5: true=1. Output: 01.
व्याख्या (हिन्दी) x=0: गलत=0; x=5: सत्य=1. आउटपुट: 01.
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); अदालत
A
1 1
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10%3=1. Output: 1.
व्याख्या (हिन्दी) 10%3=1. आउटपुट: 1.
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); अदालत
A
420 420
B
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) pop returns 42, v=0. peek=0. Output: 420.
व्याख्या (हिन्दी) पॉप रिटर्न 42, वी=0। झाँकना=0. आउटपुट: 420.
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); अदालत
A
14 14
B
12 12
C
Compile error संकलन त्रुटि
D
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.
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;}}; ए ए; ए.एच(); अदालत
A
8 8
B
4 4
C
Compile error संकलन त्रुटि
D
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.
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; अदालत
A
927 927
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
9 27 9 27
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(3)=9; cu(3)=27. Output: 927.
व्याख्या (हिन्दी) वर्ग(3)=9; घन(3)=27. आउटपुट: 927.
1824
EN + हिं
GB What is the output: template T clampT(T v,T lo,T hi){return vhi?hi:v;} cout<
IN आउटपुट क्या है: टेम्पलेट टी क्लैंपटी(टी वी,टी लो,टी हाय){रिटर्न वीएचआई?हाय:वी;} कॉउट
A
5010 5010
B
1510 1510
C
Compile error संकलन त्रुटि
D
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.
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); अदालत
A
3 3
B
2 2
C
Compile error संकलन त्रुटि
D
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.
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); अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+1=11. Output: 11.
व्याख्या (हिन्दी) 5*2=10; 10+1=11. आउटपुट: 11.
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))); अदालत
A
12 12
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+(4+5)=12. Output: 12.
व्याख्या (हिन्दी) 3+(4+5)=12. आउटपुट: 12.
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
A
15120 15120
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
15 120 15 120
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15; Product=120. Output: 15120.
व्याख्या (हिन्दी) योग=15; उत्पाद=120. आउटपुट: 15120.
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); अदालत
A
2 2
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4 and 5 are >3. count=2. Output: 2.
व्याख्या (हिन्दी) 4 और 5 >3 हैं। गिनती=2. आउटपुट: 2.
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;}); अदालत
A
9 9
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) r[2]=3^2=9. Output: 9.
व्याख्या (हिन्दी) आर[2]=3^2=9. आउटपुट: 9.
1816–1830 of 1915