OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye.

📚 101 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
101 questions

Question 61

EN + हिं
GB What is the output: template auto call(F f,Args...args){return f(args...);} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो कॉल(F f,Args...args){रिटर्न f(args...);} cout
6 6
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
🎯 Exam Perspective
OOP Using C++ ("Abstraction" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 62

EN + हिं
GB What is the output: class FSM{int state=0; public: void trans(int t){state=(state+t)%3;} int get()const{return state;}}; FSM m; m.trans(1);m.trans(2);m.trans(1); cout<
IN आउटपुट क्या है: class FSM{int state=0; सार्वजनिक: void trans(int t){state=(state+t)%3;} int get()const{return state;}}; एफएसएम एम; एम.ट्रांस(1);एम.ट्रांस(2);एम.ट्रांस(1); अदालत
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) state: 0->1->0->1. Output: 1. Wait: 0+1=1%3=1; 1+2=3%3=0; 0+1=1%3=1. Output: 1.
व्याख्या (हिन्दी) अवस्था: 0->1->0->1. आउटपुट: 1. प्रतीक्षा करें: 0+1=1%3=1; 1+2=3%3=0; 0+1=1%3=1. आउटपुट: 1.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Abstraction" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 63

EN + हिं
GB What is the output: class Command{public:virtual void exec()=0;}; class Print:public Command{string s; public:Print(string t):s(t){} void exec(){cout<> cmds; cmds.push_back(make_unique("A")); cmds.push_back(make_unique("B")); for(auto&c:cmds) c->exec();
IN आउटपुट क्या है: class Command{public:virtual void exec()=0;}; क्लास प्रिंट:पब्लिक कमांड{स्ट्रिंग एस; सार्वजनिक: प्रिंट (स्ट्रिंग टी): एस (टी) {} शून्य निष्पादन () {काउट
AB अब
BA बी ० ए
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Print A then B. Output: AB.
व्याख्या (हिन्दी) ए फिर बी प्रिंट करें। आउटपुट: एबी।
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Abstraction" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 64

EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; auto wrap=[](A* p)->function{return [p]{p->f();};}; auto fn=wrap(new B); fn();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
2 2
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::f()=2. Output: 2.
व्याख्या (हिन्दी) बी::एफ()=2. आउटपुट: 2.
🎯 Exam Perspective
OOP Using C++ ("Abstraction" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 65

EN + हिं
GB What is the output: class A{public:virtual int f()const=0;}; class B:public A{int x; public:B(int v):x(v){} int f()const override{return x;}}; auto sum=[](vector& v){int s=0;for(auto p:v)s+=p->f();return s;}; vectorv={new B(1),new B(2),new B(3)}; cout<
IN आउटपुट क्या है: class A{public:virtual int f()const=0;}; कक्षा बी:सार्वजनिक ए{int x; सार्वजनिक:बी(int v):x(v){} int f()const ओवरराइड{रिटर्न x;}}; auto sum=[](vector& v){int s=0;for(auto p:v)s+=p->f();return s;}; वेक्टरv={नया बी(1),नया बी(2),नया बी(3)}; अदालत
6 6
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Abstraction" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 66

EN + हिं
GB What is the output: template class Functor{T v; public:Functor(T x):v(x){} T operator()(T x){return v*x;}}; Functor f(3); cout<
IN आउटपुट क्या है: टेम्प्लेट क्लास फ़ंक्टर {T v; सार्वजनिक:फ़ंक्टर(T x):v(x){} T ऑपरेटर()(T x){रिटर्न v*x;}}; फ़ंक्टर f(3); अदालत
1521 1521
35 35
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(5)=15; f(7)=21. Output: 1521.
व्याख्या (हिन्दी) एफ(5)=15; एफ(7)=21. आउटपुट: 1521.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Abstraction" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 67

EN + हिं
GB What is the output: class A{public:virtual int area()const=0;}; class R:public A{int w,h;public:R(int a,int b):w(a),h(b){} int area()const{return w*h;}}; class C:public A{int r;public:C(int v):r(v){} int area()const{return r*r*3;}}; A*s[]={new R(3,4),new C(5)}; cout<area()<area();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एरिया()कॉन्स्ट=0;}; वर्ग आर:सार्वजनिक ए{int w,h;सार्वजनिक:R(int a,int b):w(a),h(b){} int क्षेत्र()const{रिटर्न w*h;}}; क्लास सी:पब्लिक ए{इंट आर;पब्लिक:सी(इंट वी):आर(वी){} इंट एरिया()कॉन्स्ट{रिटर्न आर*आर*3;}}; ए*एस[]={नया आर(3,4),नया सी(5)}; अदालत
1275 1275
Compile error संकलन त्रुटि
Undefined अपरिभाषित
12 75 12 75
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) R(3,4)=12; C(5)=75. Output: 1275.
व्याख्या (हिन्दी) आर(3,4)=12; सी(5)=75. आउटपुट: 1275.
🎯 Exam Perspective
OOP Using C++ ("Abstraction" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 68

EN + हिं
GB What is the output: auto memoize=[](auto f){map cache;return [=](auto self,int n)mutable->int{if(cache.count(n))return cache[n];return cache[n]=f(self,n);};};
IN आउटपुट क्या है: ऑटो मेमोइज़=[](ऑटो एफ){मैप कैश;रिटर्न [=](ऑटो सेल्फ,इंट एन)म्यूटेबल->इंट{इफ(कैश.काउंट(एन))रिटर्न कैश[एन];रिटर्न कैश[एन]=एफ(सेल्फ,एन);};};
Compile error संकलन त्रुटि
Works काम करता है
Undefined अपरिभाषित
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Complex usage — likely compile error without proper self-application. Compile error.
व्याख्या (हिन्दी) जटिल उपयोग - उचित स्व-अनुप्रयोग के बिना संभावित संकलन त्रुटि। संकलन त्रुटि.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Abstraction" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 69

EN + हिं
GB What is the output: class Interface{public:virtual void exec()const=0; virtual ~Interface()=default;}; class Impl:public Interface{int v; public:Impl(int x):v(x){} void exec()const override{cout< p=make_shared(5); p->exec();
IN आउटपुट क्या है: वर्ग इंटरफ़ेस{सार्वजनिक:वर्चुअल शून्य निष्पादन()const=0; आभासी ~इंटरफ़ेस()=डिफ़ॉल्ट;}; वर्ग कार्यान्वयन:सार्वजनिक इंटरफ़ेस{int v; सार्वजनिक: Impl(int x):v(x){} void exec()const ओवरराइड{cout
25 25
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Impl::exec()=5*5=25. Output: 25.
व्याख्या (हिन्दी) कार्यान्वयन::exec()=5*5=25। आउटपुट: 25.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Abstraction" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 70

EN + हिं
GB What is the output: template auto makeAdder(T n){return [n](T x){return x+n;};}; auto add5=makeAdder(5); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकएडर (T n) {रिटर्न [n] (T x) {रिटर्न x + n;};}; ऑटो ऐड5=मेकएडर(5); अदालत
815 815
Compile error संकलन त्रुटि
Undefined अपरिभाषित
8 15 8 15
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) add5(3)=8; add5(10)=15. Output: 815.
व्याख्या (हिन्दी) add5(3)=8; जोड़ें5(10)=15. आउटपुट: 815.
🎯 Exam Perspective
OOP Using C++ ("Abstraction" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 71

EN + हिं
GB What is the output: class Abstract{public:virtual int calc(int)const=0;}; class Double:public Abstract{public:int calc(int x)const override{return x*2;}}; class Triple:public Abstract{public:int calc(int x)const override{return x*3;}}; auto apply=[](Abstract*a,int x){return a->calc(x);}; cout<
IN आउटपुट क्या है: class Abstract{public:virtual int calc(int)const=0;}; वर्ग डबल:सार्वजनिक सार{सार्वजनिक:int calc(int x)const ओवरराइड{रिटर्न x*2;}}; वर्ग ट्रिपल:सार्वजनिक सार{सार्वजनिक:int calc(int x)const ओवरराइड{रिटर्न x*3;}}; स्वतः लागू=[](सार*a,int x){वापसी a->calc(x);}; अदालत
1015 1015
Compile error संकलन त्रुटि
Undefined अपरिभाषित
10 15 10 15
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Double(5)=10; Triple(5)=15. Output: 1015.
व्याख्या (हिन्दी) दोगुना(5)=10; तिगुना(5)=15. आउटपुट: 1015.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Abstraction" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 72

EN + हिं
GB What is the output: class EventBus{map>> handlers; public: void on(string e,functionf){handlers[e].push_back(f);} void emit(string e){for(auto&f:handlers[e])f();}}; EventBus bus; int x=0; bus.on("inc",[&]{x++;}); bus.on("inc",[&]{x+=2;}); bus.emit("inc"); cout<
IN आउटपुट क्या है: क्लास इवेंटबस{मैप हैंडलर; सार्वजनिक: void on(string e,functionf){handlers[e].push_back(f);} void emotional(string e){for(auto&f:handlers[e])f();}}; इवेंटबस बस; int x=0; Bus.on('inc',[&]{x++;}); बस.पर('inc',[&]{x+=2;}); बस.एमिट('inc'); अदालत
3 3
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Both handlers fire: x+=1+2=3. Output: 3.
व्याख्या (हिन्दी) दोनों हैंडलर फायर करते हैं: x+=1+2=3. आउटपुट: 3.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Abstraction" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 73

EN + हिं
GB What is the output: template T foldRight(vectorv,T init,F f){for(int i=v.size()-1;i>=0;i (1, 6, 83, 13, 4, 'What is the output: class A{public:virtual void f()=0;}; class B:public A{public:void f()override{cout<<'B';}}; auto clone=[](A*p)->A*{return new B(*dynamic_cast(p));}; auto p=new B; auto q=clone(p); q->f();
IN आउटपुट क्या है: टेम्पलेट T फोल्डराइट(वेक्टरv,T init,F f){for(int i=v.size()-1;i>=0;i (1, 6, 83, 13, 4, 'आउटपुट क्या है: वर्ग ए {सार्वजनिक: वर्चुअल शून्य एफ() = 0;}; वर्ग बी: सार्वजनिक ए {सार्वजनिक: शून्य एफ() ओवरराइड {काउटफ();
B बी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) q is new B. q->f()=B. Output: B.
व्याख्या (हिन्दी) q नया B है। q->f()=B. आउटपुट: बी.
🎯 Exam Perspective
OOP Using C++ ("Abstraction" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 74

EN + हिं
GB What is the output: class A{public:virtual void f()=0;}; class B:public A{public:void f()override{cout<<'B';}}; auto clone=[](A*p)->A*{return new B(*dynamic_cast(p));}; auto p=new B; auto q=clone(p); q->f();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल वॉयड f()=0;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:शून्य एफ()ओवरराइड{काउटफ();
B बी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) q is new B. q->f()=B. Output: B.
व्याख्या (हिन्दी) q नया B है। q->f()=B. आउटपुट: बी.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Abstraction" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 75

EN + हिं
GB What is the output: class Lazy{mutable optional cache; functionfn; public:Lazy(functionf):fn(f){} int get()const{if(!cache) cache=fn(); return *cache;}}; Lazy l([]()->int{cout<<'C';return 42;}); cout<
IN आउटपुट क्या है: क्लास आलसी {म्यूटेबल वैकल्पिक कैश; functionfn; सार्वजनिक:आलसी(फ़ंक्शनf):fn(f){} int get()const{if(!cache) कैश=fn(); वापसी *कैश;}}; आलसी l([]()->int{cout
C4242 सी4242
4242 4242
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First get(): compute=C, cache=42. Second get(): from cache=42. Output: C4242.
व्याख्या (हिन्दी) सबसे पहले प्राप्त करें(): कंप्यूट=सी, कैश=42। दूसरा प्राप्त करें (): कैश से = 42। आउटपुट: C4242.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Abstraction" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।