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 61

EN + हिं
GB What is the output: class A{public:virtual int f()const{return 1;}}; class B:public A{public:int f()const override{return 2;}}; const A *p=new B; cout<f();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एफ()कॉन्स्ट{रिटर्न 1;}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: int f() स्थिरांक ओवरराइड {वापसी 2;}}; स्थिरांक ए *पी=नया बी; अदालत
2 2
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->f() virtual dispatch: B::f()=2. Output: 2.
व्याख्या (हिन्दी) p->f() आभासी प्रेषण: B::f()=2। आउटपुट: 2.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 62

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

Question 63

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

Question 64

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

Question 65

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

Question 66

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

Question 67

EN + हिं
GB What is the output: class A{public:int x=1; virtual int g(){return x;}}; class B:public A{public:int x=2; int g()override{return x;}}; A *p=new B; cout<g()<<((B*)p)->x;
IN आउटपुट क्या है: class A{public:int x=1; वर्चुअल int g(){रिटर्न x;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int x=2; int g()ओवरराइड{वापसी x;}}; ए *पी=नया बी; अदालत
22 22
21 21
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->g()=B::g()=B::x=2; ((B*)p)->x=2. Output: 22.
व्याख्या (हिन्दी) p->g()=B::g()=B::x=2; ((बी*)पी)->x=2. आउटपुट: 22.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 68

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

Question 69

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

Question 70

EN + हिं
GB What is the output: struct A{virtual void f(){cout<<1;}}; struct B:A{void f()override{cout<<2;}}; struct C:A{void f()override{cout<<3;}}; struct D:B,C{}; D d; d.B::f(); d.C::f();
IN आउटपुट क्या है: struct A{virtual void f(){cout
23 23
12 12
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) d.B::f()=2; d.C::f()=3. Output: 23.
व्याख्या (हिन्दी) d.B::f()=2; d.C::f()=3. आउटपुट: 23.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 71

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

Question 72

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

Question 73

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

Question 74

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

Question 75

EN + हिं
GB What is the output: class A{public:void f(){cout<<'A';} void g(){f();}};class B:public A{public:void f(){cout<<'B';}};B b;b.g();
IN आउटपुट क्या है: कक्षा ए {सार्वजनिक: शून्य एफ() {काउट
A
B बी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g() is not virtual; calls A::f() by static dispatch. Output: A.
व्याख्या (हिन्दी) g() आभासी नहीं है; स्थिर प्रेषण द्वारा A::f() को कॉल करता है। आउटपुट: ए.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।