OOP Using C++ — MCQ Practice

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

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

Question 91

EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';} virtual ~A()=default;}; class B:public A{public:void f()override{cout<<'B';}}; class C:public A{public:void f()override{cout<<'C';}}; auto v=vector>{}; v.push_back(make_unique()); v.push_back(make_unique()); v.push_back(make_unique()); for(auto&p:v) p->f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
BCB बीसीबी
ABC एबीसी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B,C,B. Output: BCB.
व्याख्या (हिन्दी) बी,सी,बी. आउटपुट: बीसीबी.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 92

EN + हिं
GB What is the output: class A{protected:int x; public:A(int v):x(v){}}; class B:public A{public:B(int v):A(v){} int f(){return x*x;}}; B b(5); cout<
IN आउटपुट क्या है: class A{protected:int x; सार्वजनिक:ए(int v):x(v){}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: बी (int v): ए (v) {} int f() {वापसी x*x;}}; बी बी(5); अदालत
25 25
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=5; x*x=25. Output: 25.
व्याख्या (हिन्दी) एक्स=5; x*x=25. आउटपुट: 25.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Inheritance" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 93

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

Question 94

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

Question 95

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

Question 96

EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';}}; class B:public A{public:void f()override{cout<<'B'; A::f();}}; class C:public B{public:void f()override{cout<<'C'; B::f();}}; C c; c.f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
CBA सीबीए
ABC एबीसी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C::f()=C, B::f()=B, A::f()=A. Output: CBA.
व्याख्या (हिन्दी) सी::एफ()=सी, बी::एफ()=बी, ए::एफ()=ए। आउटपुट: सीबीए.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 97

EN + हिं
GB What is the output: class A{public:virtual void show(){cout<<"A";}}; class B:public A{public:void show()override{cout<<"B";}}; void print(A& a){a.show();} B b; print(b);
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल वॉयड शो(){काउट
B बी
A
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.show() virtual: B::show(). Output: B.
व्याख्या (हिन्दी) a.show() वर्चुअल: B::show()। आउटपुट: बी.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 98

EN + हिं
GB What is the output: class A{public:int n; A(int v):n(v){} virtual A* clone(){return new A(*this);}}; class B:public A{public:B(int v):A(v){} B* clone()override{return new B(*this);}}; A *p=new B(42); A *q=p->clone(); cout<n;
IN आउटपुट क्या है: class A{public:int n; A(int v):n(v){} वर्चुअल A* क्लोन(){नया A(*this);}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: बी (int v): ए (v) {} बी * क्लोन() ओवरराइड {नया बी लौटाएं (* यह);}}; ए *पी=नया बी(42); A *q=p->क्लोन(); अदालत
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::clone() returns new B(42). q->n=42. Output: 42.
व्याख्या (हिन्दी) B::क्लोन() नया B(42) लौटाता है। q->n=42. आउटपुट: 42.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Inheritance" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 99

EN + हिं
GB What is the output: class A{public:int x=1;}; class B:public A{public:int x=2;}; B b; A& ra=b; B& rb=b; cout<
IN आउटपुट क्या है: class A{public:int x=1;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int x=2;}; बी बी; ए&आरए=बी; बी&आरबी=बी; अदालत
12 12
22 22
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ra.x=A::x=1; rb.x=B::x=2. Output: 12.
व्याख्या (हिन्दी) ra.x=A::x=1; rb.x=B::x=2. आउटपुट: 12.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 100

EN + हिं
GB What is the output: class A{public:A(){cout<<'A';} A(const A&){cout<<'C';}};class B:public A{public:B():A(){cout<<'B';}};B b1;B b2=b1;
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
ABAC एबीएसी
ABBC एबीबीसी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b1: A(),B=AB. b2=b1: A(const A&)=C,B(implicit copy)=B... actually B's implicit copy calls A's copy: AC. Total: ABAC.
व्याख्या (हिन्दी) बी1: ए(),बी=एबी। b2=b1: A(const A&)=C,B(अंतर्निहित प्रतिलिपि)=B... वास्तव में B की अंतर्निहित प्रतिलिपि A की प्रतिलिपि को कॉल करती है: AC। कुल: एबीएसी.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 101

EN + हिं
GB What is the output: struct A{int x=1; virtual void f(){x=2;}}; struct B:A{void f()override{x=3;}}; A a; B b; A& ra=a; B& rb=b; ra.f(); rb.f(); cout<
IN आउटपुट क्या है: struct A{int x=1; आभासी शून्य f(){x=2;}}; संरचना बी:ए{शून्य एफ()ओवरराइड{x=3;}}; ए ए; बी बी; ए&आरए=ए; बी&आरबी=बी; ra.f(); आरबी.एफ(); अदालत
23 23
22 22
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ra.f(): A::f()=x=2. rb.f(): B::f()=x=3. Output: 23.
व्याख्या (हिन्दी) ra.f(): A::f()=x=2. rb.f(): B::f()=x=3. आउटपुट: 23.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Inheritance" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 102

EN + हिं
99 99
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::f()=99. Output: 99.
व्याख्या (हिन्दी) बी::एफ()=99. आउटपुट: 99.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 103

EN + हिं
GB What is the output: class A{public:int x=0; A(){} A(const A& o):x(o.x+10){}}; class B:public A{public:B(){x=5;}}; B b; A a=b; cout<
IN आउटपुट क्या है: class A{public:int x=0; A(){} A(const A& o):x(o.x+10){}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:बी(){x=5;}}; बी बी; ए ए=बी; अदालत
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Slicing: A's copy ctor called with B object (sliced to A). A::copy ctor: x=b.A::x+10=5+10=15... Wait: b.A::x=0 (A's default ctor runs first then B sets x=5). b.x (A part) = 5. A copy: x=5+10=15. Output: 15.
व्याख्या (हिन्दी) स्लाइसिंग: A की कॉपी ctor को B ऑब्जेक्ट के साथ बुलाया जाता है (A से स्लाइस किया गया)। A::copy ctor: x=b.A::x+10=5+10=15... प्रतीक्षा करें: b.A::x=0 (A का डिफ़ॉल्ट ctor पहले चलता है फिर B x=5 सेट करता है)। b.x (एक भाग) = 5. एक प्रति: x=5+10=15. आउटपुट: 15.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 104

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