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 31

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

Question 32

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

Question 33

EN + हिं

Question 34

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

Question 35

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

Question 36

EN + हिं
GB What is 'virtual inheritance' use case?
IN 'वर्चुअल इनहेरिटेंस' उपयोग मामला क्या है?
Diamond: ensure single base subobject हीरा: एकल आधार उपवस्तु सुनिश्चित करें
Performance optimization प्रदर्शन अनुकूलन
Multiple return types एकाधिक रिटर्न प्रकार
Template specialization टेम्पलेट विशेषज्ञता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) class B:virtual public A{}; class C:virtual public A{}; class D:public B,C{}; D has one A.
व्याख्या (हिन्दी) कक्षा बी:वर्चुअल पब्लिक ए{}; क्लास सी:वर्चुअल पब्लिक ए{}; कक्षा डी:सार्वजनिक बी,सी{}; D के पास एक A है.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 37

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

Question 38

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

Question 39

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); अदालत
34 34
43 43
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=3,y=4. Output: 34.
व्याख्या (हिन्दी) x=3,y=4. आउटपुट: 34.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 40

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

Question 41

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

Question 42

EN + हिं
GB What is 'covariant return type' example?
IN 'सहसंयोजक रिटर्न प्रकार' उदाहरण क्या है?
Base:virtual A* f(); Derived:B* f() where B derives A आधार:वर्चुअल ए* एफ(); व्युत्पन्न:B* f() जहां B से A प्राप्त होता है
Same return type always हमेशा एक ही रिटर्न प्रकार
Template return टेम्पलेट वापसी
void return only केवल शून्य वापसी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Overriding may return derived pointer/reference of base's return type.
व्याख्या (हिन्दी) ओवरराइडिंग से आधार के रिटर्न प्रकार का व्युत्पन्न सूचक/संदर्भ वापस आ सकता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 43

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

Question 44

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

Question 45

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;}}; A *p=new B; p->f(); cout<x;
IN आउटपुट क्या है: class A{public:int x=0; आभासी शून्य f(){x=1;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:शून्य f()ओवरराइड{x=2;}}; ए *पी=नया बी; p->f(); अदालत
2 2
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->f() dispatches to B::f(); x=2. Output: 2.
व्याख्या (हिन्दी) p->f() B::f() को भेजता है; एक्स=2. आउटपुट: 2.
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।