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
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{}}; ए *पी=नया बी; पी हटाएं; अदालत
A
X एक्स
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
UB यूबी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Virtual dtor ensures proper cleanup. Output: X.
व्याख्या (हिन्दी) वर्चुअल डीटोर उचित सफाई सुनिश्चित करता है। आउटपुट: एक्स.
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;}}; बी बी; अदालत
A
9 9
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::f()=3. h()=3*3=9. Output: 9.
व्याख्या (हिन्दी) बी::एफ()=3. एच()=3*3=9. आउटपुट: 9.
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 आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
22 22
B
12 12
C
Compile error संकलन त्रुटि
D
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.
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 आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
12 12
B
21 21
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted keys: a=A=1, b=B=2. Output: 12.
व्याख्या (हिन्दी) क्रमबद्ध कुंजियाँ: a=A=1, b=B=2. आउटपुट: 12.
91–94 of 94