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
1726
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x){}}; A f(A a){a.x*=2; return a;} A a(5); A b=f(a); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x){}}; A f(A a){a.x*=2; वापसी ए;} ए ए(5); ए बी=एफ(ए); अदालत
A
510 510
B
1010 1010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a passed by value; f doubles copy; returned copy b.x=10. a.x=5. Output: 510.
व्याख्या (हिन्दी) एक पारित मूल्य; एफ डबल्स कॉपी; लौटाई गई प्रति b.x=10. a.x=5. आउटपुट: 510.
1727
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} void print()const{cout<print(); delete p;
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} void print()const{cout
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->print()=42. Output: 42.
व्याख्या (हिन्दी) p->प्रिंट()=42. आउटपुट: 42.
1728
EN + हिं
GB What is the output: struct POD{int x,y,z;}; POD a={1,2,3}; POD b=a; b.x=10; cout<
IN आउटपुट क्या है: struct POD{int x,y,z;}; पीओडी ए={1,2,3}; पीओडी बी=ए; b.x=10; अदालत
A
110 110
B
1010 1010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b is copy; b.x=10 doesn't affect a. Output: 110.
व्याख्या (हिन्दी) बी प्रतिलिपि है; b.x=10 a को प्रभावित नहीं करता है। आउटपुट: 110.
1729
EN + हिं
GB What is the output: class A{public:int x=0; A& inc(int n=1){x+=n;return *this;} A& dec(int n=1){x-=n;return *this;}}; A a; a.inc().inc(5).dec(2); cout<
IN आउटपुट क्या है: class A{public:int x=0; A& inc(int n=1){x+=n;return *this;} A& dec(int n=1){x-=n;return *this;}}; ए ए; a.inc().inc(5).dec(2); अदालत
A
4 4
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+1+5-2=4. Output: 4.
व्याख्या (हिन्दी) 0+1+5-2=4. आउटपुट: 4.
1730
EN + हिं
1731
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){cout<<'A';} ~A(){cout<<'Z';}}; try{A a(1); A b(2); throw 1;}catch(int){cout<<'E';}
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){cout
A
AAZZE अज्जे
B
AAZZZE AAZZZE
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(1)=A; A(2)=A; throw: ~b=Z,~a=Z; catch: E. Output: AAZZE.
व्याख्या (हिन्दी) ए(1)=ए; ए(2)=ए; फेंकें: ~बी=जेड,~ए=जेड; कैच: ई. आउटपुट: AAZZE.
1732
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.
1733
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.
व्याख्या (हिन्दी) नया बी: ए, बी। हटाएं पी: ~बी(बी), ~ए(ए)। आउटपुट: एबीबीए.
1734
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.
1735
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() को कॉल करता है। आउटपुट: ए.
1736
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; class C:public B{};A*p=new C;p->f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
2 2
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C inherits B::f(). p->f()=2. Output: 2.
व्याख्या (हिन्दी) C को B::f() विरासत में मिला है। p->f()=2. आउटपुट: 2.
1737
EN + हिं
GB What is the output: class A{public:int x=10; virtual int f(){return x;}}; class B:public A{public:B(){x=20;} int f()override{return x*2;}}; A*p=new B; cout<f();
IN आउटपुट क्या है: class A{public:int x=10; वर्चुअल int f(){रिटर्न x;}}; क्लास बी:पब्लिक ए{पब्लिक:बी(){x=20;} int f()ओवरराइड{रिटर्न x*2;}}; ए*पी=नया बी; अदालत
A
40 40
B
20 20
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B() sets x=20. B::f()=20*2=40. Output: 40.
व्याख्या (हिन्दी) बी() x=20 सेट करता है। बी::एफ()=20*2=40। आउटपुट: 40.
1738
EN + हिं
GB What is the output: class A{public:virtual void f()=0; int g(){return 42;}}; class B:public A{public:void f()override{cout<
IN आउटपुट क्या है: class A{public:virtual void f()=0; int g(){वापसी 42;}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: शून्य एफ() ओवरराइड {काउट
A
42 42
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::f() calls A::g()=42. Output: 42.
व्याख्या (हिन्दी) B::f() A::g()=42 को कॉल करता है। आउटपुट: 42.
1739
EN + हिं
GB What is the output: class A{public:int x=5;}; class B:public A{}; class C:public B{}; C c; cout<
IN आउटपुट क्या है: class A{public:int x=5;}; कक्षा बी:सार्वजनिक ए{}; कक्षा सी:सार्वजनिक बी{}; सी सी; अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) c.x inherited from A. Output: 5.
व्याख्या (हिन्दी) c.x ए से विरासत में मिला है। आउटपुट: 5।
1740
EN + हिं
GB What is the output: class A{public:A(int v){cout<
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए (इंट वी) {काउट
A
123 123
B
321 321
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(1)=1, B=2, C=3. Output: 123.
व्याख्या (हिन्दी) ए(1)=1, बी=2, सी=3। आउटपुट: 123.
1726–1740 of 1915