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
61
EN + हिं
GB What is the output: class A{int x; public: void setX(int v){x=v;} int getX(){return x;} A& chain(){return *this;}}; A a; a.chain().setX(10); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: void setX(int v){x=v;} int getX(){रिटर्न x;} A& चेन(){रिटर्न *यह;}}; ए ए; a.चेन().setX(10); अदालत
A
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) chain() returns *this; setX(10) sets x=10. Output: 10.
व्याख्या (हिन्दी) चेन() रिटर्न *यह; setX(10) x=10 सेट करता है। आउटपुट: 10.
62
EN + हिं
GB What is the output: struct Point{int x,y; Point(int x,int y):x(x),y(y){}}; Point p{3,4}; cout<
IN आउटपुट क्या है: struct प्वाइंट{int x,y; बिंदु(int x,int y):x(x),y(y){}}; बिंदु p{3,4}; अदालत
A
34 34
B
43 43
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=3,y=4. Output: 34.
व्याख्या (हिन्दी) x=3,y=4. आउटपुट: 34.
63
EN + हिं
GB What is the output: class A{public: static int f(int x){return x*2;}}; cout<
IN आउटपुट क्या है: वर्ग ए {सार्वजनिक: स्थिर int f (int x) {वापसी x * 2;}}; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A::f(5)=10. Output: 10.
व्याख्या (हिन्दी) ए::एफ(5)=10. आउटपुट: 10.
64
EN + हिं
GB What is 'proxy object pattern'?
IN 'प्रॉक्सी ऑब्जेक्ट पैटर्न' क्या है?
A
Object that controls access to another object वह वस्तु जो किसी अन्य वस्तु तक पहुंच को नियंत्रित करती है
B
A smart pointer एक स्मार्ट सूचक
C
A wrapper class एक रैपर वर्ग
D
An adapter एक एडाप्टर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Proxy wraps another object, forwarding operations or adding interception (e.g., lazy loading, access control).
व्याख्या (हिन्दी) प्रॉक्सी किसी अन्य ऑब्जेक्ट को लपेटता है, संचालन को अग्रेषित करता है या अवरोधन जोड़ता है (उदाहरण के लिए, आलसी लोडिंग, एक्सेस कंट्रोल)।
65
EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} int operator%(int n)const{return x%n;}}; A a(10); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} int ऑपरेटर%(int n)const{return x%n;}}; ए ए(10); अदालत
A
1 1
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10%3=1. Output: 1.
व्याख्या (हिन्दी) 10%3=1. आउटपुट: 1.
66
EN + हिं
GB What is the output: class A{public:int x=0; void f(){x+=2;}}; A a; a.f();a.f();a.f(); cout<
IN आउटपुट क्या है: class A{public:int x=0; शून्य f(){x+=2;}}; ए ए; a.f();a.f();a.f(); अदालत
A
6 6
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+2+2+2=6. Output: 6.
व्याख्या (हिन्दी) 0+2+2+2=6. आउटपुट: 6.
67
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A operator*(const A& o){return {x*o.x};}}; A a(3),b(4); cout<<(a*b).x;
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A ऑपरेटर*(const A& o){return {x*o.x};}}; ए ए(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.
68
EN + हिं
GB What is the output: class A{int x=0; public: auto& ref(){return x;}}; A a; a.ref()=42; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: ऑटो&रेफ(){रिटर्न x;}}; ए ए; a.ref()=42; अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.ref()=42 sets x=42. a.ref()=42. Output: 42.
व्याख्या (हिन्दी) a.ref()=42 सेट x=42। a.ref()=42. आउटपुट: 42.
69
EN + हिं
GB What is the output: class A{public:int x=5;}; class B{public:A a;}; B b; cout<
IN आउटपुट क्या है: class A{public:int x=5;}; कक्षा बी{सार्वजनिक:ए ए;}; बी बी; अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.a.x=5. Output: 5.
व्याख्या (हिन्दी) b.a.x=5. आउटपुट: 5.
70
EN + हिं
GB What is the output: class A{public:int x=0; friend A operator+(A a,A b){return A(a.x+b.x); A(int v):x(v){}}};
IN आउटपुट क्या है: class A{public:int x=0; मित्र A ऑपरेटर+(A a,A b){रिटर्न A(a.x+b.x); A(int v):x(v){}}};
A
Compile error संकलन त्रुटि
B
Works काम करता है
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Constructor A(int) defined after friend inside class — ill-formed. Compile error.
व्याख्या (हिन्दी) कंस्ट्रक्टर A(int) को कक्षा के अंदर मित्र के बाद परिभाषित किया गया - गलत तरीके से बनाया गया। संकलन त्रुटि.
71
EN + हिं
GB What is the output: class A{public: int x=0; void f()&{x=1;} void f()&&{x=2;}}; A a; a.f(); cout<
IN आउटपुट क्या है: class A{public: int x=0; शून्य f()&{x=1;} शून्य f()&&{x=2;}}; ए ए; a.f(); अदालत
A
Compile error संकलन त्रुटि
B
12 12
C
11 11
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.f() lvalue: x=1. A().f() rvalue: x=2. Output: 12.
व्याख्या (हिन्दी) a.f() लाभ मान: x=1. A().f() प्रतिमूल्य: x=2. आउटपुट: 12.
72
EN + हिं
GB What is the output: class A{public:A()=delete;}; A a;
IN आउटपुट क्या है: class A{public:A()=delete;}; ए ए;
A
Compile error संकलन त्रुटि
B
Works काम करता है
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A()=delete; A a tries to call it. Compile error.
व्याख्या (हिन्दी) ए()=हटाएं; ए इसे कॉल करने का प्रयास करता है। संकलन त्रुटि.
73
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} auto operator<=>(const A&)const=default;}; A a(3),b(5); cout<<(a
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} ऑटो ऑपरेटर(const A&)const=default;}; ए ए(3),बी(5); अदालत
A
10 10
B
01 01
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3<5=1; 3==5=0. Output: 10.
व्याख्या (हिन्दी) 3
74
EN + हिं
GB What is the output: class A{public:int x=0; void inc(int n=1){x+=n;}}; A a; a.inc(); a.inc(5); cout<
IN आउटपुट क्या है: class A{public:int x=0; void inc(int n=1){x+=n;}}; ए ए; a.inc(); ए.इंक(5); अदालत
A
6 6
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) inc()=x+=1=1; inc(5)=x+=5=6. Output: 6.
व्याख्या (हिन्दी) inc()=x+=1=1; inc(5)=x+=5=6. आउटपुट: 6.
75
EN + हिं
GB What is the output: class A{public:int x=0; explicit operator bool()const{return x!=0;}}; A a; a.x=5; if(a) cout<<'Y'; else cout<<'N';
IN आउटपुट क्या है: class A{public:int x=0; स्पष्ट ऑपरेटर बूल() स्थिरांक {वापसी x!=0;}}; ए ए; a.x=5; यदि (ए) कोउट
A
Y वाई
B
N एन
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=5!=0=true. if(a)=Y. Output: Y.
व्याख्या (हिन्दी) a.x=5!=0=सत्य. यदि(ए)=वाई. आउटपुट: वाई.
61–75 of 106