OOP Using C++ — MCQ Practice

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

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

Question 91

EN + हिं
GB What is the output: class A{public:virtual void f()=0; virtual ~A()=default;}; class B:public A{public:void f()override{}}; A *p=new B; delete p; cout<<'X';
IN आउटपुट क्या है: class A{public:virtual void f()=0; आभासी ~ए()=डिफ़ॉल्ट;}; class B:public A{public:void f()override{}}; ए *पी=नया बी; पी हटाएं; अदालत
X एक्स
Compile error संकलन त्रुटि
Undefined अपरिभाषित
UB यूबी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Virtual dtor ensures proper cleanup. Output: X.
व्याख्या (हिन्दी) वर्चुअल डीटोर उचित सफाई सुनिश्चित करता है। आउटपुट: एक्स.
🎯 Exam Perspective
OOP Using C++ ("Polymorphism" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 92

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

Question 93

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

Question 94

EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; mapm;m["a"]=new A;m["b"]=new B; for(auto&[k,v]:m)v->f();
IN What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; mapm;m["a"]=new A;m["b"]=new B; for(auto&[k,v]:m)v->f();
12 12
21 21
Compile error Compile error
Undefined Undefined
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted keys: a=A=1, b=B=2. Output: 12.
व्याख्या (हिन्दी) क्रमबद्ध कुंजियाँ: a=A=1, b=B=2. आउटपुट: 12.
🎯 Exam Perspective
OOP Using C++ ("Polymorphism" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।