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
811
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(A&& o):x(o.x*2){o.x=0;}}; A a(5); A b=move(a); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(A&& o):x(o.x*2){o.x=0;}}; ए ए(5); ए बी = चाल (ए); अदालत
A
010 010
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.x=5*2=10, a.x=0. Output: 010.
व्याख्या (हिन्दी) b.x=5*2=10, a.x=0. आउटपुट: 010.
812
EN + हिं
GB What is the output: class A{int x=0; public: void f()const{cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: शून्य f()const{cout
A
50 50
B
05 05
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.f() non-const: x=5,print 5. ca.f() const: print x=0. Output: 50.
व्याख्या (हिन्दी) a.f() गैर-स्थिरांक: x=5,प्रिंट 5. ca.f() स्थिरांक: प्रिंट x=0. आउटपुट: 50.
813
EN + हिं
GB What is 'CRTP for static polymorphism'?
IN 'स्थैतिक बहुरूपता के लिए सीआरटीपी' क्या है?
A
Base<Derived>: call derived method without virtual आधार: वर्चुअल के बिना व्युत्पन्न विधि को कॉल करें
B
Runtime dispatch रनटाइम प्रेषण
C
Multiple inheritance एकाधिक वंशानुक्रम
D
Abstract class सार वर्ग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) CRTP: static_cast(this)->impl() resolves at compile time; zero virtual overhead.
व्याख्या (हिन्दी) सीआरटीपी: static_cast(this)->impl() संकलन समय पर हल हो जाता है; शून्य वर्चुअल ओवरहेड.
814
EN + हिं
GB What is the output: class Counter{int n=0; public: Counter& operator++(){n++;return *this;} int get()const{return n;}}; Counter c; ++c;++c;++c; cout<
IN आउटपुट क्या है: क्लास काउंटर{int n=0; सार्वजनिक: काउंटर और ऑपरेटर++(){n++;रिटर्न *यह;} int get()const{रिटर्न n;}}; काउंटर सी; ++सी;++सी;++सी; अदालत
A
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) n incremented 3 times. get()=3. Output: 3.
व्याख्या (हिन्दी) n 3 गुना बढ़ाया गया। प्राप्त करें()=3. आउटपुट: 3.
815
EN + हिं
GB What is the output: class A{public:A(){cout<<'C';} A(const A&){cout<<'P';} A(A&&){cout<<'M';} ~A(){cout<<'D';}}; A a=A();
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
C सी
B
CD सीडी
C
CM सेमी
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory elision: A() creates directly into a. Ctor prints C; dtor at end prints D. Output: CD.
व्याख्या (हिन्दी) C++17 अनिवार्य एलिज़न: A() सीधे a में बनता है। सीटीओआर सी प्रिंट करता है; अंत में डीटीओआर डी प्रिंट करता है। आउटपुट: सीडी।
816
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} bool operator<(const A& o)const{return x
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} बूल ऑपरेटर
A
10 10
B
01 01
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3<5=1, 5<3=0. Output: 10.
व्याख्या (हिन्दी) 3
817
EN + हिं
GB What is the output: class A{public:int x=0; void f(int v){x=v;} auto g(){return [this]{return x;};}}; A a; a.f(42); cout<
IN आउटपुट क्या है: class A{public:int x=0; शून्य f(int v){x=v;} ऑटो g(){वापसी [यह]{वापसी x;};}}; ए ए; ए.एफ(42); अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lambda captures this; returns x=42. Output: 42.
व्याख्या (हिन्दी) लैम्ब्डा ने इसे पकड़ लिया; x=42 लौटाता है। आउटपुट: 42.
818
EN + हिं
GB What is 'object layout' in C++?
IN C++ में 'ऑब्जेक्ट लेआउट' क्या है?
A
Order of data members in memory (plus padding, vptr) मेमोरी में डेटा सदस्यों का क्रम (प्लस पैडिंग, वीपीटीआर)
B
Virtual table only केवल वर्चुअल टेबल
C
Heap layout ढेर लेआउट
D
Stack layout ढेर लेआउट
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Object layout: members stored in declaration order, with alignment padding; virtual classes add vptr.
व्याख्या (हिन्दी) ऑब्जेक्ट लेआउट: सदस्यों को संरेखण पैडिंग के साथ घोषणा क्रम में संग्रहीत किया जाता है; आभासी कक्षाएँ vptr जोड़ती हैं।
819
EN + हिं
GB What is the output: class A{public:int x=5; operator bool()const{return x!=0;}}; A a; if(a) cout<<'Y'; else cout<<'N';
IN आउटपुट क्या है: class A{public:int x=5; ऑपरेटर बूल() स्थिरांक {वापसी x!=0;}}; ए ए; यदि (ए) कोउट
A
Y वाई
B
N एन
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=5!=0=true. if(a) executes. Output: Y.
व्याख्या (हिन्दी) a.x=5!=0=सत्य. यदि (ए) निष्पादित करता है। आउटपुट: वाई.
820
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.
821
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.
822
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.
823
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).
व्याख्या (हिन्दी) प्रॉक्सी किसी अन्य ऑब्जेक्ट को लपेटता है, संचालन को अग्रेषित करता है या अवरोधन जोड़ता है (उदाहरण के लिए, आलसी लोडिंग, एक्सेस कंट्रोल)।
824
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.
825
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.
811–825 of 1915