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 1756

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++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1757

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++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1758

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
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1759

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
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1760

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
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1761

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
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1762

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

Question 1763

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++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1764

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
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1765

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

Question 1766

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

Question 1767

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

Question 1768

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

Question 1769

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

Question 1770

EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()final{cout<<2;}}; A*p=new B; p->f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
2 2
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) final prevents further override but is still virtual. p->f()=B::f()=2. Output: 2.
व्याख्या (हिन्दी) फाइनल आगे ओवरराइड को रोकता है लेकिन फिर भी आभासी है। p->f()=B::f()=2. आउटपुट: 2.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।