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 1831

EN + हिं
GB What is the output: class Transform{public:virtual int apply(int x)const=0; virtual ~Transform()=default;}; class Scale:public Transform{int f;public:Scale(int v):f(v){} int apply(int x)const override{return x*f;}}; class Shift:public Transform{int s;public:Shift(int v):s(v){} int apply(int x)const override{return x+s;}}; vectorts={new Scale(2),new Shift(3)}; int v=5; for(auto t:ts)v=t->apply(v); cout<
IN आउटपुट क्या है: class Transform{public:virtual int apply(int x)const=0; आभासी ~परिवर्तन()=डिफ़ॉल्ट;}; वर्ग स्केल:सार्वजनिक ट्रांसफ़ॉर्म{int f;सार्वजनिक:स्केल(int v):f(v){} int apply(int x)const ओवरराइड{रिटर्न x*f;}}; क्लास शिफ्ट:पब्लिक ट्रांसफॉर्म{int s;public:Shift(int v):s(v){} int apply(int x)const ओवरराइड{रिटर्न x+s;}}; वेक्टरट्स={नया स्केल(2),नया शिफ्ट(3)}; int v=5; for(auto t:ts)v=t->apply(v); अदालत
13 13
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+3=13. Output: 13.
व्याख्या (हिन्दी) 5*2=10; 10+3=13. आउटपुट: 13.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1832

EN + हिं
GB What is the output: template class Optional{bool has;T v;public:Optional():has(false){} Optional(T x):has(true),v(x){} bool hasValue()const{return has;} T value()const{return v;} T valueOr(T d)const{return has?v:d;}}; Optionala(5),b; cout<
IN आउटपुट क्या है: टेम्पलेट वर्ग वैकल्पिक {बूल है; टी वी; सार्वजनिक: वैकल्पिक(): है (झूठा) {} वैकल्पिक (टी एक्स): है (सत्य), वी (एक्स) {} बूल है वैल्यू() कॉन्स्ट {रिटर्न है;} टी वैल्यू() कॉन्स्ट {रिटर्न वी;} टी वैल्यूऑर (टी डी) कॉन्स्ट {रिटर्न है? वी: डी;}}; वैकल्पिक(5),बी; अदालत
599 599
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=5, b=empty=99. Output: 599.
व्याख्या (हिन्दी) ए=5, बी=खाली=99। आउटपुट: 599.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1833

EN + हिं
GB What is the output: class Visitor{public:virtual void visitInt(int x)=0; virtual void visitStr(const string& s)=0;}; class Print:public Visitor{public:void visitInt(int x)override{cout<
IN आउटपुट क्या है: वर्ग विज़िटर{सार्वजनिक:वर्चुअल शून्य विज़िटइंट(int x)=0; आभासी शून्य विज़िटStr(const string& s)=0;}; वर्ग प्रिंट:सार्वजनिक विज़िटर{सार्वजनिक:शून्य विज़िटइंट(int x)ओवरराइड{काउट
42hi 42हि
Compile error संकलन त्रुटि
Undefined अपरिभाषित
hi42 हाय42
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42 then hi. Output: 42hi.
व्याख्या (हिन्दी) 42 फिर हाय. आउटपुट: 42हाय.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1834

EN + हिं
GB What is the output: template struct IsPrime{static const bool v=[](){for(int i=2;i*i<=N;i++)if(N%i==0)return false;return N>1;}();}; cout<::v<::v;
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर IsPrime{static const bool v=[](){for(int i=2;i*i1;}();}; cout
10 10
11 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7 prime=1; 9=3*3 not prime=0. Output: 10.
व्याख्या (हिन्दी) 7 अभाज्य=1; 9=3*3 अभाज्य=0 नहीं। आउटपुट: 10.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1835

EN + हिं
GB What is the output: class A{public:virtual string repr()const=0;}; class Int:public A{int v;public:Int(int x):v(x){} string repr()const override{return to_string(v);}}; class Str:public A{string s;public:Str(string t):s(t){} string repr()const override{return '"'+s+'"';}}; vectorv={new Int(42),new Str("hi")}; for(auto p:v)cout<repr()<<' ';
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल स्ट्रिंग रिप्र()कॉन्स्ट=0;}; क्लास इंट:पब्लिक ए{इंट वी;पब्लिक:इंट(इंट एक्स):वी(एक्स){} स्ट्रिंग रिप्र()कॉन्स्ट ओवरराइड{रिटर्न टू_स्ट्रिंग(वी);}}; क्लास स्ट्र:पब्लिक ए{स्ट्रिंग एस;पब्लिक:स्ट्र(स्ट्रिंग टी):एस(टी){} स्ट्रिंग रिप्र()कॉन्स्ट ओवरराइड{रिटर्न '''+एस+''';}}; वेक्टरv={नया इंट(42),नया स्ट्र('हाय')}; for(auto p:v)cout
42 "hi" 42 "हाय"
Compile error संकलन त्रुटि
Undefined अपरिभाषित
42hi 42हि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42 and "hi". Output: 42 "hi".
व्याख्या (हिन्दी) 42 और "हाय"। आउटपुट: 42 "हाय"।
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1836

EN + हिं
GB What is the output: template T identity_(T x){return x;} template T applyFn(F f,T x){return f(x);} cout<,5);
IN आउटपुट क्या है: टेम्प्लेट T पहचान_(T x){रिटर्न x;} टेम्प्लेट T अप्लाईFn(F f,T x){रिटर्न f(x);} कॉउट
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) identity_(5)=5. Output: 5.
व्याख्या (हिन्दी) पहचान_(5)=5. आउटपुट: 5.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1837

EN + हिं
GB What is the output: class Lens{int A::*ptr; public:Lens(int A::*p):ptr(p){} int get(const A& a)const{return a.*ptr;} void set(A& a,int v)const{a.*ptr=v;}}; struct A{int x=0,y=0;}; Lens lx(&A::x); A a; lx.set(a,5); cout<
IN आउटपुट क्या है: क्लास लेंस{int A::*ptr; सार्वजनिक:लेंस(int A::*p):ptr(p){} int get(const A& a)const{return a.*ptr;} void set(A& a,int v)const{a.*ptr=v;}}; संरचना A{int x=0,y=0;}; लेंस lx(&A::x); ए ए; एलएक्स.सेट(ए,5); अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) lx.set sets a.x=5; lx.get returns 5. Output: 5.
व्याख्या (हिन्दी) lx.set सेट a.x=5; lx.get रिटर्न 5. आउटपुट: 5.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1838

EN + हिं

Question 1839

EN + हिं
GB What is the output: template auto sumTuple(tuplet){return apply([](auto...xs){return (xs+...);},t);} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो sumTuple(tuplet){return apply([](auto...xs){return (xs+...);},t);} cout
15 15
Compile error संकलन त्रुटि
Undefined अपरिभाषित
5 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 1+2+3+4+5=15. आउटपुट: 15.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1840

EN + हिं
GB What is the output: class Cache{mapm; functionf; public:Cache(functionfn):f(fn){} int get(int x){if(!m.count(x))m[x]=f(x);return m[x];}}; Cache sq([](int x){return x*x;}); cout<
IN आउटपुट क्या है: class Cache{mapm; फ़ंक्शनएफ; public:Cache(functionfn):f(fn){} int get(int x){if(!m.count(x))m[x]=f(x);return m[x];}}; कैश sq([](int x){रिटर्न x*x;}); अदालत
25259 25259
Compile error संकलन त्रुटि
Undefined अपरिभाषित
25 25 9 25 25 9
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(5)=25 (computed); sq(5)=25 (cached); sq(3)=9. Output: 25259.
व्याख्या (हिन्दी) वर्ग(5)=25 (गणना); वर्ग(5)=25 (कैश्ड); वर्ग(3)=9. आउटपुट: 25259.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1841

EN + हिं
GB What is the output: class A{public:virtual int eval()const=0;}; class Const:public A{int v;public:Const(int x):v(x){} int eval()const override{return v;}}; class Mul:public A{A *l,*r;public:Mul(A*a,A*b):l(a),r(b){} int eval()const override{return l->eval()*r->eval();}}; A*e=new Mul(new Const(3),new Mul(new Const(4),new Const(5))); cout<eval();
IN आउटपुट क्या है: class A{public:virtual int eval()const=0;}; वर्ग स्थिरांक:सार्वजनिक A{int v;सार्वजनिक:Const(int x):v(x){} int eval()const ओवरराइड{रिटर्न v;}}; क्लास मुल:पब्लिक ए{ए *एल,*आर;पब्लिक:मुल(ए*ए,ए*बी):एल(ए),आर(बी){} int eval()const ओवरराइड{रिटर्न l->eval()*r->eval();}}; ए*ई=नया मूल(नया स्थिरांक(3),नया मूल(नया स्थिरांक(4),नया स्थिरांक(5))); अदालत
60 60
20 20
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4*5=20; 3*20=60. Output: 60.
व्याख्या (हिन्दी) 4*5=20; 3*20=60. आउटपुट: 60.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1842

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

Question 1843

EN + हिं
GB What is the output: class Protocol{public:virtual void send(string)=0; virtual string recv()=0;}; class Echo:public Protocol{string last; public:void send(string s)override{last=s;} string recv()override{return last;}}; Echo e; e.send("hello"); cout<
IN आउटपुट क्या है: क्लास प्रोटोकॉल{पब्लिक:वर्चुअल वॉयड सेंड(स्ट्रिंग)=0; वर्चुअल स्ट्रिंग recv()=0;}; कक्षा इको: सार्वजनिक प्रोटोकॉल {स्ट्रिंग अंतिम; सार्वजनिक:शून्य भेजें(स्ट्रिंग s)ओवरराइड{अंतिम=s;} स्ट्रिंग recv()ओवरराइड{अंतिम वापसी;}}; इको ई; ई.भेजें('हैलो'); अदालत
hello नमस्ते
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) recv returns last sent. Output: hello.
व्याख्या (हिन्दी) recv रिटर्न अंतिम बार भेजा गया। आउटपुट: नमस्ते.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1844

EN + हिं
GB What is the output: template auto pipeline(T x){return x;} template auto pipeline(T x,F f,Fs...fs){return pipeline(f(x),fs...);} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो पाइपलाइन(T x){रिटर्न x;} टेम्पलेट ऑटो पाइपलाइन(T x,F f,Fs...fs){रिटर्न पाइपलाइन(f(x),fs...);} cout
169 169
100 100
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+3=13; 13^2=169. Output: 169.
व्याख्या (हिन्दी) 5*2=10; 10+3=13; 13^2=169. आउटपुट: 169.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1845

EN + हिं
GB What is the output: class A{public:virtual int f()const=0; int g()const{return f()*f()+f();}}; class B:public A{public:int f()const override{return 3;}}; B b; cout<
IN आउटपुट क्या है: class A{public:virtual int f()const=0; int g()const{return f()*f()+f();}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: int f() स्थिरांक ओवरराइड {वापसी 3;}}; बी बी; अदालत
12 12
9 9
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3*3+3=12. Output: 12.
व्याख्या (हिन्दी) 3*3+3=12. आउटपुट: 12.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।