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
61
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;}}; const A *p=new B; cout<f();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एफ()कॉन्स्ट{रिटर्न 1;}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: int f() स्थिरांक ओवरराइड {वापसी 2;}}; स्थिरांक ए *पी=नया बी; अदालत
A
2 2
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->f() virtual dispatch: B::f()=2. Output: 2.
व्याख्या (हिन्दी) p->f() आभासी प्रेषण: B::f()=2। आउटपुट: 2.
62
EN + हिं
GB What is the output: class A{public:int x=1; virtual int f(){return x;}}; class B:public A{public:int x=2; int f()override{return x;}}; B b; A&r=b; cout<
IN आउटपुट क्या है: class A{public:int x=1; वर्चुअल int f(){रिटर्न x;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int x=2; int f()ओवरराइड{रिटर्न x;}}; बी बी; ए&आर=बी; अदालत
A
21 21
B
22 22
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) r.f()=B::f()=2; r.x=A::x=1. Output: 21.
व्याख्या (हिन्दी) r.f()=B::f()=2; r.x=A::x=1. आउटपुट: 21.
63
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';}}; class B:public A{public:void f()override{cout<<'B';}}; class C:public B{}; C c; c.f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
B बी
B
A
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C inherits B::f which overrides A::f. Output: B.
व्याख्या (हिन्दी) C को B::f विरासत में मिला है जो A::f को ओवरराइड करता है। आउटपुट: बी.
64
EN + हिं
GB What is the output: class A{public:int x=0; A(int v):x(v){} virtual void f(){cout<
IN आउटपुट क्या है: class A{public:int x=0; A(int v):x(v){} आभासी शून्य f(){cout
A
6 6
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(3*2=6): x=6. f()=6. Output: 6.
व्याख्या (हिन्दी) ए(3*2=6): एक्स=6। एफ()=6. आउटपुट: 6.
65
EN + हिं
GB What is the output: class A{public:void f(){cout<<'A';}}; class B:public A{public:using A::f; void f(int){cout<<'B';}}; B b; b.f();
IN आउटपुट क्या है: कक्षा ए {सार्वजनिक: शून्य एफ() {काउट
A
A
B
B बी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) using A::f makes A::f(void) accessible. b.f()=A::f. Output: A.
व्याख्या (हिन्दी) A::f का उपयोग करने से A::f(void) पहुंच योग्य हो जाता है। b.f()=A::f. आउटपुट: ए.
66
EN + हिं
GB What is the output: class A{public:A(int){cout<<'P';} virtual void f()=0;}; class B:public A{public:B():A(5){cout<<'B';} void f()override{cout<<'F';}}; B b; b.f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए (इंट) {काउट
A
PBF पीबीएफ
B
BPF बीपीएफ
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(5)=P; B()=B; b.f()=F. Output: PBF.
व्याख्या (हिन्दी) ए(5)=पी; बी()=बी; बी.एफ()=एफ. आउटपुट: पीबीएफ।
67
EN + हिं
GB What is the output: class A{public:int x=1; virtual int g(){return x;}}; class B:public A{public:int x=2; int g()override{return x;}}; A *p=new B; cout<g()<<((B*)p)->x;
IN आउटपुट क्या है: class A{public:int x=1; वर्चुअल int g(){रिटर्न x;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int x=2; int g()ओवरराइड{वापसी x;}}; ए *पी=नया बी; अदालत
A
22 22
B
21 21
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->g()=B::g()=B::x=2; ((B*)p)->x=2. Output: 22.
व्याख्या (हिन्दी) p->g()=B::g()=B::x=2; ((बी*)पी)->x=2. आउटपुट: 22.
68
EN + हिं
GB What is the output: class A{public:virtual ~A(){cout<<'A';}}; class B:public A{public:~B()override{cout<<'B';}}; class C:public B{public:~C()override{cout<<'C';}}; A*p=new C; delete p;
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल ~ए(){काउट
A
CBA सीबीए
B
ABC एबीसी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ~C, ~B, ~A in order. Output: CBA.
व्याख्या (हिन्दी) ~सी, ~बी, ~ए क्रम में। आउटपुट: सीबीए.
69
EN + हिं
GB What is the output: class A{public:int x=0;}; class B:public A{public:int x=1;}; class C:public A{public:int x=2;}; class D:public B,public C{}; D d; cout<
IN आउटपुट क्या है: class A{public:int x=0;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int x=1;}; कक्षा सी:सार्वजनिक ए{सार्वजनिक:int x=2;}; कक्षा डी:सार्वजनिक बी,सार्वजनिक सी{}; डी डी; अदालत
A
12 12
B
01 01
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) d.B::x=1; d.C::x=2. Output: 12.
व्याख्या (हिन्दी) d.B::x=1; d.C::x=2. आउटपुट: 12.
70
EN + हिं
GB What is the output: struct A{virtual void f(){cout<<1;}}; struct B:A{void f()override{cout<<2;}}; struct C:A{void f()override{cout<<3;}}; struct D:B,C{}; D d; d.B::f(); d.C::f();
IN आउटपुट क्या है: struct A{virtual void f(){cout
A
23 23
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) d.B::f()=2; d.C::f()=3. Output: 23.
व्याख्या (हिन्दी) d.B::f()=2; d.C::f()=3. आउटपुट: 23.
71
EN + हिं
GB What is the output: class A{protected:int x=5;}; class B:public A{public: int getX(){return x;}}; class C:public A{public: int getX(){return x+1;}}; B b; C c; cout<
IN आउटपुट क्या है: class A{protected:int x=5;}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: int getX() {वापसी x;}}; कक्षा सी:सार्वजनिक ए{सार्वजनिक: int getX(){रिटर्न x+1;}}; बी बी; सी सी; अदालत
A
56 56
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.getX()=5; c.getX()=6. Output: 56.
व्याख्या (हिन्दी) b.getX()=5; c.getX()=6. आउटपुट: 56.
72
EN + हिं
GB What is the output: class A{public:int x=1; virtual int f(){return x;}}; class B:public A{public:int x=2; int f()override{return x;}}; B b; cout<
IN आउटपुट क्या है: class A{public:int x=1; वर्चुअल int f(){रिटर्न x;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int x=2; int f()ओवरराइड{रिटर्न x;}}; बी बी; अदालत
A
212 212
B
221 221
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.x=B::x=2; b.A::x=1; b.f()=B::f()=B::x=2. Output: 212.
व्याख्या (हिन्दी) b.x=B::x=2; b.A::x=1; b.f()=B::f()=B::x=2. आउटपुट: 212.
73
EN + हिं
GB What is the output: class A{public:A(){cout<<'A';} virtual ~A(){cout<<'a';}}; class B:public A{public:B(){cout<<'B';} ~B(){cout<<'b';}}; A*p=new B; delete p;
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
ABba एबीबीए
B
ABab अबाब
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) new B: A,B. delete p: ~B(b), ~A(a). Output: ABba.
व्याख्या (हिन्दी) नया बी: ए, बी। हटाएं पी: ~बी(बी), ~ए(ए)। आउटपुट: एबीबीए.
74
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); अदालत
A
12 12
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3*4=12. Output: 12.
व्याख्या (हिन्दी) 3*4=12. आउटपुट: 12.
75
EN + हिं
GB What is the output: class A{public:void f(){cout<<'A';} void g(){f();}};class B:public A{public:void f(){cout<<'B';}};B b;b.g();
IN आउटपुट क्या है: कक्षा ए {सार्वजनिक: शून्य एफ() {काउट
A
A
B
B बी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g() is not virtual; calls A::f() by static dispatch. Output: A.
व्याख्या (हिन्दी) g() आभासी नहीं है; स्थिर प्रेषण द्वारा A::f() को कॉल करता है। आउटपुट: ए.
61–75 of 104