OOP Using C++ — MCQ Practice

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

📚 1915 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
1915 questions
1741
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 आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
B बी
B
A
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g() calls virtual f(): B::f()=B. Output: B.
व्याख्या (हिन्दी) g() वर्चुअल f() को कॉल करता है: B::f()=B। आउटपुट: बी.
1742
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;}}; ए ए; बी बी; सी सी; अदालत
A
123 123
B
111 111
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A::f()=1, B::f()=2, C::f()=3. Output: 123.
व्याख्या (हिन्दी) ए::एफ()=1, बी::एफ()=2, सी::एफ()=3। आउटपुट: 123.
1743
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){}}; क्लास डी:पब्लिक बी
A
B() बी()
B
3 3
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
1744
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),बी(),सी(){}}; डी डी; अदालत
A
3 3
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Most derived class D initializes virtual base A(3). x=3. Output: 3.
व्याख्या (हिन्दी) अधिकांश व्युत्पन्न वर्ग डी आभासी आधार ए(3) को आरंभ करता है। एक्स=3. आउटपुट: 3.
1745
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
A
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
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। आउटपुट: ए.
1746
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 आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
3234 3234
B
1234 1234
C
Compile error संकलन त्रुटि
D
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.
1747
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(); अदालत
A
4 4
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Each inc() adds 2. 2+2=4. Output: 4.
व्याख्या (हिन्दी) प्रत्येक inc() 2 जोड़ता है। 2+2=4। आउटपुट: 4.
1748
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;}}; स्थिरांक ए*पी=नया बी; अदालत
A
2 2
B
3 3
C
Compile error संकलन त्रुटि
D
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.
1749
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); बी सी=बी; अदालत
A
34 34
B
00 00
C
Compile error संकलन त्रुटि
D
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.
1750
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); अदालत
A
25 25
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*5=25. Output: 25.
व्याख्या (हिन्दी) 5*5=25. आउटपुट: 25.
1751
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';} virtual ~A()=default;}; class B:public A{public:void f()override{cout<<'B';}}; class C:public A{public:void f()override{cout<<'C';}}; auto v=vector>{}; v.push_back(make_unique()); v.push_back(make_unique()); v.push_back(make_unique()); for(auto&p:v) p->f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
BCB बीसीबी
B
ABC एबीसी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B,C,B. Output: BCB.
व्याख्या (हिन्दी) बी,सी,बी. आउटपुट: बीसीबी.
1752
EN + हिं
GB What is the output: class A{protected:int x; public:A(int v):x(v){}}; class B:public A{public:B(int v):A(v){} int f(){return x*x;}}; B b(5); cout<
IN आउटपुट क्या है: class A{protected:int x; सार्वजनिक:ए(int v):x(v){}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: बी (int v): ए (v) {} int f() {वापसी x*x;}}; बी बी(5); अदालत
A
25 25
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=5; x*x=25. Output: 25.
व्याख्या (हिन्दी) एक्स=5; x*x=25. आउटपुट: 25.
1753
EN + हिं
GB What is the output: class A{public:virtual void f()=0;}; class B:public A{public:void f()override{cout<<1;}}; auto fp=&B::f; B b; (b.*fp)();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल वॉयड f()=0;}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: शून्य एफ() ओवरराइड {काउट
A
1 1
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) fp is pointer to B::f. (b.*fp)()=1. Output: 1.
व्याख्या (हिन्दी) fp B::f का सूचक है। (बी.*एफपी)()=1. आउटपुट: 1.
1754
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;} void g(){A::f();}}; B b; b.g(); cout<
IN आउटपुट क्या है: class A{public:int x=0; आभासी शून्य f(){x=1;}}; वर्ग बी:सार्वजनिक ए{सार्वजनिक:शून्य एफ()ओवरराइड{x=2;} शून्य जी(){ए::एफ();}}; बी बी; b.g(); अदालत
A
1 1
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.g() calls A::f() explicitly: x=1. Output: 1.
व्याख्या (हिन्दी) b.g() स्पष्ट रूप से A::f() को कॉल करता है: x=1। आउटपुट: 1.
1755
EN + हिं
GB What is the output: class A{public:int x; A(int v=0):x(v){}}; class B:public A{public:B(int v):A(v*2){}}; class C:public B{public:C(int v):B(v+1){}}; C c(2); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v=0):x(v){}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:बी(int v):ए(v*2){}}; कक्षा सी:सार्वजनिक बी{सार्वजनिक:सी(int v):बी(v+1){}}; सी सी(2); अदालत
A
6 6
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C(2): B(3): A(6). x=6. Output: 6.
व्याख्या (हिन्दी) सी(2): बी(3): ए(6)। एक्स=6. आउटपुट: 6.
1741–1755 of 1915