OOP Using C++ — MCQ Practice

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

📚 107 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
107 questions

Question 16

EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} operator int(){return x;}}; A a(5); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} ऑपरेटर int(){return x;}}; ए ए(5); अदालत
8 8
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) operator int() converts a to 5. 5+3=8. Output: 8.
व्याख्या (हिन्दी) ऑपरेटर int() a को 5 में परिवर्तित करता है। 5+3=8। आउटपुट: 8.
🎯 Exam Perspective
OOP Using C++ ("Encapsulation" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 17

EN + हिं
GB What is 'access specifier' in C++?
IN C++ में 'एक्सेस स्पेसिफायर' क्या है?
public, protected, private — controls member visibility सार्वजनिक, संरक्षित, निजी - सदस्य दृश्यता को नियंत्रित करता है
const, volatile modifiers स्थिरांक, अस्थिर संशोधक
Virtual and override keywords वर्चुअल और ओवरराइड कीवर्ड
Static and extern keywords स्थैतिक और बाहरी कीवर्ड
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Access specifiers (public/protected/private) define which code can access class members.
व्याख्या (हिन्दी) एक्सेस स्पेसिफायर (सार्वजनिक/संरक्षित/निजी) परिभाषित करते हैं कि कौन सा कोड क्लास सदस्यों तक पहुंच सकता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Encapsulation" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 18

EN + हिं
GB What is the output: class A{int x=0; public: A& operator++(){x++; return *this;} int get()const{return x;}}; A a; ++a; ++a; ++a; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: A& ऑपरेटर++(){x++; रिटर्न *यह;} int get()const{रिटर्न x;}}; ए ए; ++ए; ++ए; ++ए; अदालत
3 3
1 1
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Each prefix ++ increments x. After 3 calls, x=3. Output: 3.
व्याख्या (हिन्दी) प्रत्येक उपसर्ग ++ x को बढ़ाता है। 3 कॉल के बाद, x=3. आउटपुट: 3.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Encapsulation" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 19

EN + हिं
GB What is 'const correctness'?
IN 'स्थिरांक शुद्धता' क्या है?
Using const wherever possible to prevent unintended modification अनपेक्षित संशोधन को रोकने के लिए जहां भी संभव हो const का उपयोग करना
Making all methods const सभी विधियों को स्थिरांक बनाना
Immutable objects only केवल अपरिवर्तनीय वस्तुएँ
Const member initialization कॉन्स्ट सदस्य आरंभीकरण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Const correctness means marking member functions const when they don't modify state, and const objects/references where appropriate.
व्याख्या (हिन्दी) कॉन्स्ट शुद्धता का मतलब है कि जब सदस्य फ़ंक्शन स्थिति को संशोधित नहीं करते हैं तो कॉन्स्ट को चिह्नित करना, और जहां उपयुक्त हो वहां कॉन्स्ट ऑब्जेक्ट/संदर्भों को चिह्नित करना।
🎯 Exam Perspective
OOP Using C++ ("Encapsulation" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 20

EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} bool operator==(const A&o)const{return x==o.x;}}; A a(5),b(5); cout<<(a==b);
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} bool ऑपरेटर==(const A&o)const{return x==o.x;}}; ए ए(5),बी(5); अदालत
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) operator== compares x values: 5==5=true=1. Output: 1.
व्याख्या (हिन्दी) ऑपरेटर== x मानों की तुलना करता है: 5==5=सही=1। आउटपुट: 1.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Encapsulation" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 21

EN + हिं
GB What is the output: class A{int x=5; public: void print()const{cout<
IN आउटपुट क्या है: class A{int x=5; सार्वजनिक: शून्य प्रिंट() स्थिरांक {cout
5 5
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) const object can call const member functions. print() outputs x=5. Output: 5.
व्याख्या (हिन्दी) कॉन्स्ट ऑब्जेक्ट कॉन्स्ट सदस्य फ़ंक्शंस को कॉल कर सकता है। प्रिंट() आउटपुट x=5। आउटपुट: 5.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Encapsulation" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 22

EN + हिं
GB What is 'interface segregation' and encapsulation?
IN 'इंटरफ़ेस पृथक्करण' और एनकैप्सुलेशन क्या है?
Many specific interfaces better than one general interface कई विशिष्ट इंटरफ़ेस एक सामान्य इंटरफ़ेस से बेहतर हैं
Hiding all members सभी सदस्यों को छुपाया जा रहा है
Using private inheritance निजी विरासत का उपयोग करना
Abstract base class only केवल सार आधार वर्ग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Interface segregation (ISP) means clients shouldn't depend on interfaces they don't use — relates to well-encapsulated design.
व्याख्या (हिन्दी) इंटरफ़ेस पृथक्करण (आईएसपी) का मतलब है कि ग्राहकों को उन इंटरफेस पर निर्भर नहीं रहना चाहिए जिनका वे उपयोग नहीं करते हैं - यह अच्छी तरह से इनकैप्सुलेटेड डिज़ाइन से संबंधित है।
🎯 Exam Perspective
OOP Using C++ ("Encapsulation" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 23

EN + हिं
GB What is the output: class A{int x=0; public: int get()const{return x;} void set(int v){if(v>0) x=v;}}; A a; a.set(-5); cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: int get()const{return x;} void set(int v){if(v>0) x=v;}}; ए ए; ए.सेट(-5); अदालत
-5 -5
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) set() validates: -5 is not >0, so x stays 0. get()=0. Output: 0.
व्याख्या (हिन्दी) सेट() मान्य करता है: -5 >0 नहीं है, इसलिए x 0 ही रहता है। get()=0। आउटपुट: 0.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Encapsulation" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 24

EN + हिं
GB What is the output: class A{int x; public: A(int v=0):x(v){} int operator+(const A&o)const{return x+o.x;}}; A a(3),b(4); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v=0):x(v){} int ऑपरेटर+(const A&o)const{return x+o.x;}}; ए ए(3),बी(4); अदालत
7 7
12 12
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) operator+ returns x+o.x = 3+4=7. Output: 7.
व्याख्या (हिन्दी) ऑपरेटर+ रिटर्न x+o.x = 3+4=7. आउटपुट: 7.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Encapsulation" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 25

EN + हिं
GB What is 'friend class' in C++?
IN C++ में 'फ्रेंड क्लास' क्या है?
Class with access to another class's private/protected members किसी अन्य वर्ग के निजी/संरक्षित सदस्यों तक पहुंच वाला वर्ग
Derived class व्युत्पन्न वर्ग
Inner class आंतरिक वर्ग
Same-package class समान-पैकेज वर्ग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A friend class declaration inside a class grants all of that friend class's methods access to private/protected members.
व्याख्या (हिन्दी) किसी वर्ग के अंदर एक मित्र वर्ग की घोषणा उस मित्र वर्ग के सभी तरीकों को निजी/संरक्षित सदस्यों तक पहुंच प्रदान करती है।
🎯 Exam Perspective
OOP Using C++ ("Encapsulation" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 26

EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} friend ostream& operator<<(ostream& os,const A& a){os<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} मित्र ओस्ट्रीम& ऑपरेटर
99 99
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Friend operator<< accesses private x=99. Output: 99.
व्याख्या (हिन्दी) मित्र संचालिका
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Encapsulation" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 27

EN + हिं
GB What is the purpose of making constructors private?
IN कंस्ट्रक्टर्स को निजी बनाने का उद्देश्य क्या है?
Singleton pattern — prevents direct instantiation सिंगलटन पैटर्न - प्रत्यक्ष इन्स्टेन्शियशन को रोकता है
Performance optimization प्रदर्शन अनुकूलन
Preventing inheritance वंशानुक्रम को रोकना
Abstract class creation सार वर्ग निर्माण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Private constructors enforce patterns like Singleton, where object creation is controlled through a factory method.
व्याख्या (हिन्दी) निजी कंस्ट्रक्टर सिंगलटन जैसे पैटर्न लागू करते हैं, जहां ऑब्जेक्ट निर्माण को फ़ैक्टरी विधि के माध्यम से नियंत्रित किया जाता है।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Encapsulation" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 28

EN + हिं
GB What is the output: class A{int x=1,y=2; public: int sum()const{return x+y;} void scale(int f){x*=f; y*=f;}}; A a; a.scale(3); cout<
IN आउटपुट क्या है: class A{int x=1,y=2; सार्वजनिक: int sum() स्थिरांक {वापसी x + y;} शून्य स्केल (int f) {x * = f; y*=f;}}; ए ए; ए.स्केल(3); अदालत
9 9
3 3
6 6
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=1*3=3, y=2*3=6. sum()=3+6=9. Output: 9.
व्याख्या (हिन्दी) x=1*3=3, y=2*3=6. योग()=3+6=9. आउटपुट: 9.
🎯 Exam Perspective
OOP Using C++ ("Encapsulation" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 29

EN + हिं
GB What is 'module' in C++20 related to encapsulation?
IN C++20 में एनकैप्सुलेशन से संबंधित 'मॉड्यूल' क्या है?
Replaces header files; exports only declared interface हेडर फ़ाइलों को प्रतिस्थापित करता है; केवल घोषित इंटरफ़ेस निर्यात करता है
Like namespaces नामस्थान की तरह
Dynamic loading गतिशील लोडिंग
Separate compilation units अलग संकलन इकाइयाँ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++20 modules improve encapsulation by explicitly controlling what is exported from a compilation unit.
व्याख्या (हिन्दी) C++20 मॉड्यूल एक संकलन इकाई से निर्यात की जाने वाली चीज़ों को स्पष्ट रूप से नियंत्रित करके इनकैप्सुलेशन में सुधार करते हैं।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Encapsulation" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 30

EN + हिं
GB What is the output: class A{int x; public: void setX(int v){x=v;} int getX()const{return x;}}; A a; cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: void setX(int v){x=v;} int getX()const{return x;}}; ए ए; अदालत
Undefined behavior अपरिभाषित व्यवहार
Compile error संकलन त्रुटि
Garbage कचरा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x is uninitialized; reading it is undefined behavior (no in-class initializer, no constructor initialization). Output: UB.
व्याख्या (हिन्दी) x अप्रारंभीकृत है; इसे पढ़ना अपरिभाषित व्यवहार है (कोई इन-क्लास इनिशियलाइज़र नहीं, कोई कंस्ट्रक्टर इनिशियलाइज़ेशन नहीं)। आउटपुट: यूबी.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Encapsulation" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।