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
796
EN + हिं
GB What is the output: class A{public:int x; A(int v=0):x(v){}}; A a[3]; cout<
IN आउटपुट क्या है: class A{public:int x; A(int v=0):x(v){}}; ए ए[3]; अदालत
A
000 000
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
123 123
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default ctor A() sets x=0. All elements x=0. Output: 000.
व्याख्या (हिन्दी) डिफ़ॉल्ट ctor A() x=0 सेट करता है। सभी तत्व x=0. आउटपुट: 000.
797
EN + हिं
GB What is the output: class A{public:int x; A():x(0){} A(const A& o):x(o.x+1){}}; A a; A b=a; A c=b; cout<
IN आउटपुट क्या है: class A{public:int x; A():x(0){} A(const A& o):x(o.x+1){}}; ए ए; ए बी=ए; ए सी=बी; अदालत
A
012 012
B
000 000
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=0; b.x=a.x+1=1; c.x=b.x+1=2. Output: 012.
व्याख्या (हिन्दी) a.x=0; b.x=a.x+1=1; c.x=b.x+1=2. आउटपुट: 012.
798
EN + हिं
GB What is the output: class A{public:int x=0; A& inc(){x++;return *this;}}; A a; cout<
IN आउटपुट क्या है: class A{public:int x=0; A& inc(){x++;रिटर्न *यह;}}; ए ए; अदालत
A
3 3
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Each inc() increments x; chained. x=3. Output: 3.
व्याख्या (हिन्दी) प्रत्येक inc() वेतन वृद्धि x; जंजीर. एक्स=3. आउटपुट: 3.
799
EN + हिं
GB What is 'aggregate initialization' for class?
IN कक्षा के लिए 'समग्र आरंभीकरण' क्या है?
A
Class with no user-defined ctor, no private data: A a{1,2}; बिना उपयोगकर्ता-परिभाषित ctor वाला वर्ग, कोई निजी डेटा नहीं: A a{1,2};
B
Any class कोई भी वर्ग
C
POD only केवल पीओडी
D
Struct only केवल संरचना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++20 relaxed: no user-provided ctor, no private non-static members, no virtual functions.
व्याख्या (हिन्दी) C++20 में छूट: कोई उपयोगकर्ता द्वारा प्रदत्त ctor नहीं, कोई निजी गैर-स्थैतिक सदस्य नहीं, कोई वर्चुअल फ़ंक्शन नहीं।
800
EN + हिं
GB What is the output: class A{public:int x,y; A(int a,int b):x(a),y(b){} int sum()const{return x+y;}}; A a(3,4); cout<
IN आउटपुट क्या है: class A{public:int x,y; A(int a,int b):x(a),y(b){} int sum()const{return x+y;}}; ए ए(3,4); अदालत
A
7 7
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+4=7. Output: 7.
व्याख्या (हिन्दी) 3+4=7. आउटपुट: 7.
801
EN + हिं
GB What is the output: class A{public:int x=10; int f(int y){return x+y;}}; A a; cout<
IN आउटपुट क्या है: class A{public:int x=10; int f(int y){रिटर्न x+y;}}; ए ए; अदालत
A
15 15
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10+5=15. Output: 15.
व्याख्या (हिन्दी) 10+5=15. आउटपुट: 15.
802
EN + हिं
GB What is 'friend function' accessing private?
IN प्राइवेट एक्सेसिंग 'फ्रेंड फंक्शन' क्या है?
A
Declared inside class; can access private members कक्षा के अंदर घोषित; निजी सदस्यों तक पहुंच सकते हैं
B
Must be member सदस्य होना चाहिए
C
Cannot access protected सुरक्षित तक पहुंच नहीं हो सकती
D
C++17 only केवल सी++17
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) friend void f(A&); inside class grants f access to A's private/protected members.
व्याख्या (हिन्दी) मित्र शून्य f(A&); अंदर की कक्षा ए के निजी/संरक्षित सदस्यों तक पहुंच प्रदान करती है।
803
EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} friend int get(A a){return a.x;}}; A a(42); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} मित्र int get(A a){return a.x;}}; ए ए(42); अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) get() is friend; accesses a.x=42. Output: 42.
व्याख्या (हिन्दी) get() मित्र है; a.x=42 तक पहुँचता है। आउटपुट: 42.
804
EN + हिं
GB What is the output: class A{public: A(){} A(A&&)=delete;}; A f(){return A();} A a=f();
IN आउटपुट क्या है: वर्ग A{सार्वजनिक: A(){} A(A&&)=delete;}; A f(){वापसी A();} A a=f();
A
Compile error संकलन त्रुटि
B
OK (compiles) ठीक है (संकलन)
C
Undefined अपरिभाषित
D
No output उत्पादन नही
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory copy elision: return A() doesn't invoke any constructor; compiles even with deleted move. Output: OK (compiles, no output).
व्याख्या (हिन्दी) C++17 अनिवार्य प्रतिलिपि elision: रिटर्न A() किसी भी कंस्ट्रक्टर को आमंत्रित नहीं करता है; हटाई गई चाल के साथ भी संकलित करता है। आउटपुट: ठीक है (संकलन, कोई आउटपुट नहीं)।
805
EN + हिं
GB What is the output: class A{public:int v; A(int x):v(x){} A operator+(const A& o){return A(v+o.v);}}; A a(3),b(4); cout<<(a+b).v;
IN आउटपुट क्या है: class A{public:int v; A(int x):v(x){} A ऑपरेटर+(const A& o){return A(v+o.v);}}; ए ए(3),बी(4); अदालत
A
7 7
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+4=7. Output: 7.
व्याख्या (हिन्दी) 3+4=7. आउटपुट: 7.
806
EN + हिं
GB What is 'non-static data member initializer'?
IN 'नॉन-स्टैटिक डेटा मेंबर इनिशियलाइज़र' क्या है?
A
int x=5; inside class body — default member value int x=5; क्लास बॉडी के अंदर - डिफ़ॉल्ट सदस्य मान
B
Static member init स्टेटिक सदस्य init
C
Const member कॉन्स्ट सदस्य
D
Constructor only केवल कंस्ट्रक्टर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++11: class A{int x=5;}; x is initialized to 5 if constructor doesn't override it.
व्याख्या (हिन्दी) सी++11: कक्षा ए{int x=5;}; यदि कंस्ट्रक्टर इसे ओवरराइड नहीं करता है तो x को 5 से प्रारंभ किया जाता है।
807
EN + हिं
GB What is the output: class A{public:int x=1,y=2,z=3; int sum(){return x+y+z;}}; A a; a.x=10; cout<
IN आउटपुट क्या है: class A{public:int x=1,y=2,z=3; int sum(){रिटर्न x+y+z;}}; ए ए; a.x=10; अदालत
A
15 15
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10+2+3=15. Output: 15.
व्याख्या (हिन्दी) 10+2+3=15. आउटपुट: 15.
808
EN + हिं
GB What is 'this pointer' type?
IN 'यह सूचक' प्रकार क्या है?
A
T* const (in non-const member) or const T* const (in const member) T* const (गैर-const सदस्य में) या const T* const (const सदस्य में)
B
T* always टी* हमेशा
C
const T* always स्थिरांक टी* हमेशा
D
void* खालीपन*
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) In non-const: this is T* const; in const member: const T* const.
व्याख्या (हिन्दी) गैर-स्थिरांक में: यह T* स्थिरांक है; स्थिरांक सदस्य में: स्थिरांक टी* स्थिरांक।
809
EN + हिं
GB What is the output: class A{int x; public: explicit A(int v):x(v){} int get()const{return x;}}; A a(5); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: स्पष्ट A(int v):x(v){} int get()const{return x;}}; ए ए(5); अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Explicit ctor sets x=5. get()=5. Output: 5.
व्याख्या (हिन्दी) स्पष्ट ctor सेट x=5. प्राप्त करें()=5. आउटपुट: 5.
810
EN + हिं
GB What is 'std::move' on class object?
IN क्लास ऑब्जेक्ट पर 'std::move' क्या है?
A
Casts to rvalue reference, enabling move constructor मूव कंस्ट्रक्टर को सक्षम करते हुए, संदर्भ को प्रतिस्थापित करने के लिए कास्ट किया जाता है
B
Copies the object ऑब्जेक्ट की प्रतिलिपि बनाता है
C
Deletes the object ऑब्जेक्ट को हटा देता है
D
Makes object const ऑब्जेक्ट स्थिरांक बनाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::move(x) is static_cast(x); enables move semantics without copying.
व्याख्या (हिन्दी) std::move(x) static_cast(x) है; नकल किए बिना शब्दार्थ को स्थानांतरित करने में सक्षम बनाता है।
796–810 of 1915