OOP Using C++ — MCQ Practice

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

📚 106 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
106 questions
91
EN + हिं
GB What is the output: class A{public:int x,y; A(int a,int b):x(a),y(b){} auto operator<=>(const A&)const=default;}; A a{1,2},b{1,3}; cout<<(a
IN आउटपुट क्या है: class A{public:int x,y; A(int a,int b):x(a),y(b){} ऑटो ऑपरेटर(const A&)const=default;}; ए ए{1,2},बी{1,3}; अदालत
A
10 10
B
01 01
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lexicographic: (1,2)<(1,3)=1; (1,2)==(1,3)=0. Output: 10.
व्याख्या (हिन्दी) शब्दकोष: (1,2)
92
EN + हिं
GB What is the output: class A{int x; public: A(int v=0):x(v){} int get()const{return x;} A operator+(const A& o)const{return A(x+o.x);} A operator*(const A& o)const{return A(x*o.x);}}; A a(2),b(3),c(4); cout<<(a+b*c).get();
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v=0):x(v){} int get()const{return x;} एक ऑपरेटर+(const A& o)const{return A(x+o.x);} एक ऑपरेटर*(const A& o)const{return A(x*o.x);}}; ए ए(2),बी(3),सी(4); अदालत
A
14 14
B
20 20
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b*c=12; a+12=14. Output: 14.
व्याख्या (हिन्दी) बी*सी=12; ए+12=14. आउटपुट: 14.
93
EN + हिं
GB What is the output: struct Point{int x=0,y=0; Point& move(int dx,int dy){x+=dx;y+=dy;return *this;}}; Point p; p.move(1,2).move(3,4); cout<
IN आउटपुट क्या है: struct प्वाइंट{int x=0,y=0; बिंदु और चाल(int dx,int dy){x+=dx;y+=dy;वापसी *यह;}}; Point p; p.move(1,2).move(3,4); अदालत
A
46 46
B
13 13
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+1+3=4, 0+2+4=6. Output: 46.
व्याख्या (हिन्दी) 0+1+3=4, 0+2+4=6. आउटपुट: 46.
94
EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} auto operator*(const A& o)const{return A(x*o.x);} int get()const{return x;}}; A a(2); auto r=a*a*a; cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} ऑटो ऑपरेटर*(const A& o)const{return A(x*o.x);} int get()const{return x;}}; ए ए(2); ऑटो r=a*a*a; अदालत
A
8 8
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2*2=4; 4*2=8. Output: 8.
व्याख्या (हिन्दी) 2*2=4; 4*2=8. आउटपुट: 8.
95
EN + हिं
GB What is the output: class Ratio{int n,d; public:Ratio(int a,int b):n(a),d(b){} double val()const{return (double)n/d;}}; Ratio r(3,4); cout<
IN आउटपुट क्या है: वर्ग अनुपात {int n,d; सार्वजनिक:अनुपात(int a,int b):n(a),d(b){} डबल वैल()const{रिटर्न (डबल)n/d;}}; अनुपात r(3,4); अदालत
A
0.75 0.75
B
0.5 0.5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3/4=0.75. Output: 0.75.
व्याख्या (हिन्दी) 3/4=0.75. आउटपुट: 0.75.
96
EN + हिं
GB What is the output: class A{int x=5; public:int get()const{return x;} friend bool eq(A a,A b){return a.x==b.x;}}; A a,b; cout<
IN आउटपुट क्या है: class A{int x=5; सार्वजनिक:int get()const{return x;} मित्र bool eq(A a,A b){return a.x==b.x;}}; ए ए, बी; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Both x=5. eq=1. Output: 1.
व्याख्या (हिन्दी) दोनों x=5. eq=1. आउटपुट: 1.
97
EN + हिं
GB What is the output: class A{public:int x=0; auto operator[](int i)->int&{x=i;return x;}}; A a; a[5]=10; cout<
IN आउटपुट क्या है: class A{public:int x=0; ऑटो ऑपरेटर[](int i)->int&{x=i;return x;}}; ए ए; ए[5]=10; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[5]: x=5, returns x. a[5]=10: assigns 10 to x. Output: 10.
व्याख्या (हिन्दी) a[5]: x=5, x लौटाता है। a[5]=10: x को 10 निर्दिष्ट करता है। आउटपुट: 10.
98
EN + हिं
GB What is the output: class A{public:vectorv; void push(int x){v.push_back(x);} int sum()const{return accumulate(v.begin(),v.end(),0);}}; A a; a.push(1);a.push(2);a.push(3); cout<
IN आउटपुट क्या है: class A{public:vectorv; शून्य पुश(int x){v.push_back(x);} int sum()const{रिटर्न एक्युमेटेड(v.begin(),v.end(),0);}}; ए ए; ए.पुश(1);ए.पुश(2);ए.पुश(3); अदालत
A
6 6
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
99
EN + हिं
GB 'What is the output: class A{static int count; public:A(){count++;} ~A(){count (1, 6, 78, 8, 4, 'What is the output: class A{public:int x=10; A* self(){return this;}}; A a; cout<x;', 'this pointer return?', '10', '10', 'Compile error', 'Compile error', 'Undefined', 'Undefined', '0', '0', NULL, 'option_a', 'self() returns this; ->x=10. Output: 10.', 0, '2026-05-25', '2026-05-25'), (1, 6, 78, 8, 4, 'What is the output: class A{public:int x; A(int v):x(v){} bool isPositive()const{return x>0;} bool isEven()const{return x%2==0;}}; A a(4); cout<0=1; 4%2==0=1. Output: 11.', 0, '2026-05-25', '2026-05-25'), (1, 6, 78, 8, 4, 'What is the output: class A{int x=5; public:operator string()const{return to_string(x);}}; A a; string s=a; cout<
IN 'आउटपुट क्या है: क्लास ए {स्टेटिक इंट काउंट; सार्वजनिक:ए(){गिनती++;} ~ए(){गिनती (1, 6, 78, 8, 4, 'आउटपुट क्या है: क्लास ए{पब्लिक:इंट x=10; ए* सेल्फ(){इसे लौटाएं;}}; ए ए; कॉउटएक्स=10। आउटपुट: 10.', 0, '2026-05-25', '2026-05-25'), (1, 6, 78, 8, 4, 'आउटपुट क्या है: वर्ग ए {सार्वजनिक: int x; A (int v): x (v) {} bool isPositive() const {return x>0;} bool isEven() const {return x%2==0;}}; A a(4); cout
A
Move with elision (C++17)? एलिज़न (सी++17) के साथ आगे बढ़ें?
B
C5 सी 5
C
CM5 सीएम5
D
CCD5 सीसीडी5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) option_a
व्याख्या (हिन्दी) विकल्प_ए
100
EN + हिं
GB What is the output: class A{public:int x=10; A* self(){return this;}}; A a; cout<x;
IN आउटपुट क्या है: class A{public:int x=10; A* self(){इसे वापस करो;}}; ए ए; अदालत
A
10 10
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) self() returns this; ->x=10. Output: 10.
व्याख्या (हिन्दी) self() इसे लौटाता है; ->x=10. आउटपुट: 10.
101
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} bool isPositive()const{return x>0;} bool isEven()const{return x%2==0;}}; A a(4); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} bool isPositive()const{return x>0;} bool isEven()const{return x%2==0;}}; ए ए(4); अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4>0=1; 4%2==0=1. Output: 11.
व्याख्या (हिन्दी) 4>0=1; 4%2==0=1. आउटपुट: 11.
102
EN + हिं
GB What is the output: class A{int x=5; public:operator string()const{return to_string(x);}}; A a; string s=a; cout<
IN आउटपुट क्या है: class A{int x=5; सार्वजनिक:ऑपरेटर स्ट्रिंग() स्थिरांक {वापसी_स्ट्रिंग (x);}}; ए ए; स्ट्रिंग एस=ए; अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) to_string(5)="5"; size=1. Output: 15.
व्याख्या (हिन्दी) to_string(5)='5'; आकार=1. आउटपुट: 15.
103
EN + हिं
GB What is the output: class A{public:int x; constexpr A(int v):x(v){} constexpr int sq()const{return x*x;}}; constexpr A a(4); constexpr int r=a.sq(); cout<
IN आउटपुट क्या है: class A{public:int x; constexpr A(int v):x(v){} constexpr int sq()const{return x*x;}}; constexpr ए ए(4); constexpr int r=a.sq(); अदालत
A
16 16
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.sq()=16. Output: 16.
व्याख्या (हिन्दी) a.sq()=16. आउटपुट: 16.
104
EN + हिं
GB What is the output: class A{public:int x=0; void f(int v=x){}};
IN आउटपुट क्या है: class A{public:int x=0; शून्य f(int v=x){}};
A
Compile error संकलन त्रुटि
B
Works काम करता है
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default argument cannot refer to non-static member. Compile error.
व्याख्या (हिन्दी) डिफ़ॉल्ट तर्क गैर-स्थैतिक सदस्य को संदर्भित नहीं कर सकता। संकलन त्रुटि.
105
EN + हिं
GB What is the output: class A{public: int x; A(int v):x(v){} friend ostream& operator<<(ostream&os,const A&a){return os<
IN आउटपुट क्या है: क्लास ए {सार्वजनिक: int x; A(int v):x(v){} मित्र ओस्ट्रीम& ऑपरेटर
A
42 42
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Friend operator<< outputs x=42. Output: 42.
व्याख्या (हिन्दी) मित्र संचालिका
91–105 of 106