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
1666
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int* mid=a+2; cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int* मध्य=ए+2; अदालत
A
12345 12345
B
34512 34512
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) mid=a+2. mid[-2]=1,mid[-1]=2,mid[0]=3,mid[1]=4,mid[2]=5. Output: 12345.
व्याख्या (हिन्दी) मध्य=ए+2. मध्य[-2]=1,मध्य[-1]=2,मध्य[0]=3,मध्य[1]=4,मध्य[2]=5. आउटपुट: 12345.
1667
EN + हिं
GB What is the output: int x=0; auto p=&x; for(int i=0;i<5;++i) ++*p; cout<
IN आउटपुट क्या है: int x=0; ऑटो पी=&x; for(int i=0;i
A
5 5
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p is x; incremented 5 times. Output: 5.
व्याख्या (हिन्दी) *पी एक्स है; 5 गुना वृद्धि. आउटपुट: 5.
1668
EN + हिं
GB What is the output: struct P{int x,y;}; P a{3,4}; P *p=&a; cout<x*p->x+p->y*p->y;
IN आउटपुट क्या है: struct P{int x,y;}; पी ए{3,4}; पी *पी=&ए; coutx+p->y*p->y;
A
25 25
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 9+16=25. Output: 25.
व्याख्या (हिन्दी) 9+16=25. आउटपुट: 25.
1669
EN + हिं
GB What is the output: int a[]={2,4,6,8,10}; for(auto *p=rbegin(a);p!=rend(a);++p) cout<<*p;
IN आउटपुट क्या है: int a[]={2,4,6,8,10}; for(auto *p=rbegin(a);p!=rend(a);++p) cout
A
10 8 6 4 2 10 8 6 4 2
B
108642 108642
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Outputs 10,8,6,4,2. Output: 108642.
व्याख्या (हिन्दी) आउटपुट 10,8,6,4,2. आउटपुट: 108642.
1670
EN + हिं
GB What is the output: class A{public:int x=0; A& add(int v){x+=v;return *this;} A& mul(int v){x*=v;return *this;}}; A a; cout<
IN आउटपुट क्या है: class A{public:int x=0; A& add(int v){x+=v;return *this;} A& mul(int v){x*=v;return *this;}}; ए ए; अदालत
A
14 14
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+3=3; +4=7; *2=14. Output: 14.
व्याख्या (हिन्दी) 0+3=3; +4=7; *2=14. आउटपुट: 14.
1671
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A operator-()const{return A(-x);}}; A a(5); cout<<(-a).x;
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A ऑपरेटर-()const{return A(-x);}}; ए ए(5); अदालत
A
-5 -5
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (-a).x=-5. Output: -5.
व्याख्या (हिन्दी) (-a).x=-5. आउटपुट:-5.
1672
EN + हिं
GB What is the output: class A{public:int x=0; A(int v=0):x(v){} bool operator<(const A& o)const{return xv={{5},{3},{8},{1}}; sort(v.begin(),v.end()); cout<
IN आउटपुट क्या है: class A{public:int x=0; A(int v=0):x(v){} बूल ऑपरेटर
A
18 18
B
81 81
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,3,5,8. v[0].x=1,v[3].x=8. Output: 18.
व्याख्या (हिन्दी) क्रमबद्ध: 1,3,5,8. v[0].x=1,v[3].x=8. आउटपुट: 18.
1673
EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} int get()const{return x;} A& operator=(const A& o){x=o.x; return *this;}}; A a(3),b(5); a=b=A(10); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} int get()const{return x;} A& ऑपरेटर=(const A& o){x=o.x; वापसी *यह;}}; ए ए(3),बी(5); ए=बी=ए(10); अदालत
A
1010 1010
B
35 35
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b=A(10): b.x=10; a=b: a.x=10. Output: 1010.
व्याख्या (हिन्दी) b=A(10): b.x=10; a=b: a.x=10. आउटपुट: 1010.
1674
EN + हिं
GB What is the output: class Vec{public:double x,y; Vec(double a,double b):x(a),y(b){} double dot(const Vec& v)const{return x*v.x+y*v.y;}}; Vec a(1,2),b(3,4); cout<
IN आउटपुट क्या है: class Vec{public:double x,y; Vec(double a,double b):x(a),y(b){} डबल डॉट(const Vec& v)const{return x*v.x+y*v.y;}}; Vec a(1,2),b(3,4); अदालत
A
11 11
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*3+2*4=11. Output: 11.
व्याख्या (हिन्दी) 1*3+2*4=11. आउटपुट: 11.
1675
EN + हिं
GB What is the output: class A{public:int x=0; void set(int v){x=v;} void reset(){x=0;} int get()const{return x;}}; A a; a.set(5); cout<
IN आउटपुट क्या है: class A{public:int x=0; शून्य सेट(int v){x=v;} शून्य रीसेट(){x=0;} int get()const{return x;}}; ए ए; ए.सेट(5); अदालत
A
50 50
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 then 0. Output: 50.
व्याख्या (हिन्दी) 5 फिर 0. आउटपुट: 50.
1676
EN + हिं
GB What is the output: class A{public:int data[3]; A(int a,int b,int c){data[0]=a;data[1]=b;data[2]=c;} int& operator[](int i){return data[i];}}; A a(1,2,3); a[1]=10; cout<
IN आउटपुट क्या है: क्लास ए{पब्लिक:इंट डेटा[3]; A(int a,int b,int c){data[0]=a;data[1]=b;data[2]=c;} int& ऑपरेटर[](int i){return data[i];}}; ए ए(1,2,3); ए[1]=10; अदालत
A
1103 1103
B
123 123
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[1]=10. Output: 1103.
व्याख्या (हिन्दी) ए[1]=10. आउटपुट: 1103.
1677
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A operator+(int n)const{return A(x+n);} friend A operator+(int n,const A& a){return A(n+a.x);}}; A a(5); cout<<(a+3).x<<(3+a).x;
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A ऑपरेटर+(int n)const{रिटर्न A(x+n);} मित्र A ऑपरेटर+(int n,const A& a){रिटर्न A(n+a.x);}}; ए ए(5); अदालत
A
88 88
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
8 8 8 8
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a+3=8; 3+a=8. Output: 88.
व्याख्या (हिन्दी) ए+3=8; 3+ए=8. आउटपुट: 88.
1678
EN + हिं
GB What is the output: class A{int x=1; public: class B{int y=2; public: void f(A& a){cout<
IN आउटपुट क्या है: class A{int x=1; सार्वजनिक: वर्ग B{int y=2; सार्वजनिक: शून्य f(A&a){cout
A
3 3
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
2 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::f accesses A::x=1. 1+2=3. Output: 3.
व्याख्या (हिन्दी) B::f A::x=1 तक पहुँचता है। 1+2=3. आउटपुट: 3.
1679
EN + हिं
GB What is the output: class A{public:int v; explicit A(int x):v(x){} explicit operator int()const{return v;}}; A a(5); cout<<(int)a;
IN आउटपुट क्या है: class A{public:int v; स्पष्ट A(int x):v(x){} स्पष्ट ऑपरेटर int()const{return v;}}; ए ए(5); अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) explicit operator int: explicit cast works. Output: 5.
व्याख्या (हिन्दी) स्पष्ट ऑपरेटर int: स्पष्ट कास्ट काम करता है। आउटपुट: 5.
1680
EN + हिं
GB What is the output: class A{public:int x=5; int f()const{return x;} int g(){return x*2;}}; const A a; cout<
IN आउटपुट क्या है: class A{public:int x=5; int f()const{रिटर्न x;} int g(){रिटर्न x*2;}}; स्थिरांक ए ए; अदालत
A
5 5
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) const A calls f()=5. Output: 5.
व्याख्या (हिन्दी) स्थिरांक A f()=5 कहता है। आउटपुट: 5.
1666–1680 of 1915