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 76

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

Question 77

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

Question 78

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

Question 79

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

Question 80

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

Question 81

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

Question 82

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

Question 83

EN + हिं
GB 'What is the output: class A{public:static int n; A(){n++;} ~A(){n (1, 6, 80, 10, 4, 'What is the output: class A{public:int x; A(int v):x(v){}}; class B:virtual public A{public:B():A(1){}}; class C:virtual public A{public:C():A(2){}}; class D:public B
IN 'आउटपुट क्या है: क्लास ए{पब्लिक:स्टैटिक इंट एन; A(){n++;} ~A(){n (1, 6, 80, 10, 4, 'आउटपुट क्या है: क्लास ए{पब्लिक:इंट एक्स; ए(इंट वी):एक्स(वी){}}; क्लास बी:वर्चुअल पब्लिक ए{पब्लिक:बी():ए(1){}}; क्लास सी:वर्चुअल पब्लिक ए{पब्लिक:सी():ए(2){}}; क्लास डी:पब्लिक बी
B() बी()
3 3
1 1
Compile error संकलन त्रुटि
✅ Correct Answer:
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Inheritance" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 84

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

Question 85

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

Question 86

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

Question 87

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

Question 88

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;} int f(){return 3;}}; const A*p=new B; cout<f();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एफ()कॉन्स्ट{रिटर्न 1;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f()const ओवरराइड{रिटर्न 2;} int f(){रिटर्न 3;}}; स्थिरांक ए*पी=नया बी; अदालत
2 2
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p is const A*; virtual const f(); dispatches to B::f()const=2. Output: 2.
व्याख्या (हिन्दी) p स्थिरांक A* है; आभासी स्थिरांक f(); B::f()const=2 को भेजता है। आउटपुट: 2.
🎯 Exam Perspective
OOP Using C++ ("Inheritance" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 89

EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(const A&o)=default;}; class B:public A{public:int y; B(int a,int b):A(a),y(b){}}; B b(3,4); B c=b; cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(const A&o)=default;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int y; B(int a,int b):A(a),y(b){}}; बी बी(3,4); बी सी=बी; अदालत
34 34
00 00
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default copy ctor copies all: c.x=3,c.y=4. Output: 34.
व्याख्या (हिन्दी) डिफ़ॉल्ट कॉपी ctor सभी कॉपी करता है: c.x=3,c.y=4. आउटपुट: 34.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Inheritance" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 90

EN + हिं
GB What is the output: class Shape{public:virtual double area()=0; double perimeter(){return 0;}}; class Sq:public Shape{double s; public:Sq(double v):s(v){} double area()override{return s*s;}}; Sq sq(5); cout<
IN आउटपुट क्या है: क्लास शेप{पब्लिक:वर्चुअल डबल एरिया()=0; दोहरा परिधि(){वापसी 0;}}; वर्ग वर्ग:सार्वजनिक आकार{डबल एस; सार्वजनिक: वर्ग (डबल वी): एस (वी) {} डबल एरिया() ओवरराइड {रिटर्न एस * एस;}}; वर्ग वर्ग(5); अदालत
25 25
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*5=25. Output: 25.
व्याख्या (हिन्दी) 5*5=25. आउटपुट: 25.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।