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

Question 16

EN + हिं
GB What is 'aggregate initialization'?
IN 'समग्र आरंभीकरण' क्या है?
Initializing aggregate types with brace-enclosed list ब्रेस-संलग्न सूची के साथ समुच्चय प्रकारों को प्रारंभ करना
Initializing arrays only केवल आरंभिक सरणियाँ
Virtual class initialization वर्चुअल क्लास आरंभीकरण
Constructor with multiple params एकाधिक पैरामीटर वाला कंस्ट्रक्टर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Aggregates (classes with no user-defined constructors, etc.) can be initialized with {val1, val2, ...}.
व्याख्या (हिन्दी) एग्रीगेट्स (बिना उपयोगकर्ता-परिभाषित कंस्ट्रक्टर वाली कक्षाएं, आदि) को {val1, val2, ...} के साथ प्रारंभ किया जा सकता है।
🎯 Exam Perspective
OOP Using C++ ("Classes and Objects" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 17

EN + हिं
GB What is the output: class A{public: int x=10; int f() const {return x;}}; const A a; cout<
IN आउटपुट क्या है: class A{public: int x=10; int f() स्थिरांक {वापसी x;}}; स्थिरांक ए ए; अदालत
10 10
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) const object can only call const member functions. f() is const and returns x=10.
व्याख्या (हिन्दी) कॉन्स्ट ऑब्जेक्ट केवल कॉन्स्ट सदस्य फ़ंक्शंस को कॉल कर सकता है। f() स्थिरांक है और x=10 लौटाता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Classes and Objects" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 18

EN + हिं
GB What is 'explicit' constructor?
IN 'स्पष्ट' कंस्ट्रक्टर क्या है?
Prevents implicit conversion of constructor argument कंस्ट्रक्टर तर्क के अंतर्निहित रूपांतरण को रोकता है
Makes constructor public कंस्ट्रक्टर को सार्वजनिक बनाता है
Forces inline expansion इनलाइन विस्तार को बल देता है
Deletes copy constructor कॉपी कंस्ट्रक्टर को हटाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) explicit prevents the constructor from being used in implicit conversions or copy-initialization.
व्याख्या (हिन्दी) स्पष्ट कन्स्ट्रक्टर को अंतर्निहित रूपांतरण या प्रतिलिपि-प्रारंभिकरण में उपयोग करने से रोकता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Classes and Objects" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 19

EN + हिं
GB What is the output: class A{public: static void f(){cout<<'S';} void g(){cout<<'G';}}; A::f(); A a; a.g();
IN आउटपुट क्या है: क्लास ए {सार्वजनिक: स्थिर शून्य एफ() {काउट
SG एसजी
GS जी एस
Compile error संकलन त्रुटि
SS एसएस
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A::f() calls static f, prints S. a.g() calls instance g, prints G. Output: SG.
व्याख्या (हिन्दी) A::f() स्टेटिक f को कॉल करता है, S को प्रिंट करता है। a.g() इंस्टेंस g को कॉल करता है, G को प्रिंट करता है। आउटपुट: SG।
🎯 Exam Perspective
OOP Using C++ ("Classes and Objects" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 20

EN + हिं
GB What is the output: class A{public: int x; A(int v=0):x(v){}}; A a=5; cout<
IN आउटपुट क्या है: क्लास ए {सार्वजनिक: int x; A(int v=0):x(v){}}; ए ए=5; अदालत
5 5
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A a=5 uses implicit conversion (copy-initialization): calls A(5), x=5. Output: 5.
व्याख्या (हिन्दी) A a=5 अंतर्निहित रूपांतरण (कॉपी-इनिशियलाइज़ेशन) का उपयोग करता है: A(5), x=5 को कॉल करता है। आउटपुट: 5.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Classes and Objects" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 21

EN + हिं
GB What is a 'nested class' in C++?
IN C++ में 'नेस्टेड क्लास' क्या है?
A class defined inside another class एक वर्ग को दूसरे वर्ग के अंदर परिभाषित किया गया है
A class with multiple inheritance एकाधिक वंशानुक्रम वाला एक वर्ग
A template class एक टेम्पलेट क्लास
Abstract class सार वर्ग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A nested class is defined within the scope of an enclosing class.
व्याख्या (हिन्दी) एक नेस्टेड वर्ग को एक संलग्न वर्ग के दायरे में परिभाषित किया गया है।
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Classes and Objects" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 22

EN + हिं
GB What is the output: class A{public: ~A(){cout<<'D';}}; A *p=new A; delete p;
IN आउटपुट क्या है: क्लास ए {सार्वजनिक: ~ ए() {काउट
D डी
Nothing कुछ नहीं
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) delete p calls destructor, which prints D.
व्याख्या (हिन्दी) डिलीट पी कॉल डिस्ट्रक्टर, जो डी प्रिंट करता है।
🎯 Exam Perspective
OOP Using C++ ("Classes and Objects" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 23

EN + हिं
GB What is 'method chaining' in C++?
IN C++ में 'मेथड चेनिंग' क्या है?
Returning *this from member functions to chain calls *इसे सदस्य फ़ंक्शंस से चेन कॉल पर लौटाना
Calling multiple methods sequentially एकाधिक विधियों को क्रमिक रूप से कॉल करना
Virtual method dispatch आभासी विधि प्रेषण
Template method pattern टेम्पलेट विधि पैटर्न
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Returning *this from methods enables: obj.setX(1).setY(2).setZ(3) style chaining.
व्याख्या (हिन्दी) तरीकों से इसे वापस करने से सक्षम होता है: obj.setX(1).setY(2).setZ(3) स्टाइल चेनिंग।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Classes and Objects" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 24

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

Question 25

EN + हिं
GB What is 'CRTP' (Curiously Recurring Template Pattern)?
IN 'सीआरटीपी' (क्यूरियसली रिकरिंग टेम्पलेट पैटर्न) क्या है?
Base class template parameterized with derived class बेस क्लास टेम्पलेट को व्युत्पन्न क्लास के साथ पैरामीटरयुक्त किया गया है
Recursive template instantiation पुनरावर्ती टेम्पलेट इन्स्टेन्शियशन
Multiple inheritance pattern एकाधिक वंशानुक्रम पैटर्न
Virtual function replacement वर्चुअल फ़ंक्शन प्रतिस्थापन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) CRTP: template class Base{}; class Derived: public Base{}; enables static polymorphism.
व्याख्या (हिन्दी) सीआरटीपी: टेम्पलेट क्लास बेस{}; वर्ग व्युत्पन्न: सार्वजनिक आधार{}; स्थैतिक बहुरूपता को सक्षम बनाता है।
🎯 Exam Perspective
OOP Using C++ ("Classes and Objects" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 26

EN + हिं
GB What is the output: class A{public: int x=5; int& f(){return x;}}; A a; a.f()=10; cout<
IN आउटपुट क्या है: class A{public: int x=5; int& f(){रिटर्न x;}}; ए ए; a.f()=10; अदालत
5 5
10 10
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() returns reference to x. Assigning 10 to it sets x=10. Output: 10.
व्याख्या (हिन्दी) f() x का संदर्भ लौटाता है। इसमें 10 निर्दिष्ट करने पर x=10 सेट हो जाता है। आउटपुट: 10.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Classes and Objects" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 27

EN + हिं
GB What is the output: class A{int x=0; public: void inc(){x++;} int get()const{return x;}}; A a,b=a; a.inc(); cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: void inc(){x++;} int get()const{return x;}}; ए ए,बी=ए; a.inc(); अदालत
10 10
11 11
01 01
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b is a copy of a (x=0). a.inc() makes a.x=1. b.x stays 0. Output: 10.
व्याख्या (हिन्दी) b, a (x=0) की एक प्रति है। a.inc() a.x=1 बनाता है। b.x 0 रहता है। आउटपुट: 10।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Classes and Objects" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 28

EN + हिं
GB What is 'type punning' in C++?
IN C++ में 'टाइप पनिंग' क्या है?
Reinterpreting memory as different type स्मृति को भिन्न प्रकार के रूप में पुनःव्याख्या करना
Type aliasing with typedef टाइपडिफ के साथ अलियासिंग टाइप करें
Template specialization टेम्पलेट विशेषज्ञता
Dynamic casting गतिशील कास्टिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Type punning reads object representation as a different type, often via union or memcpy, sometimes undefined behavior with pointer casts.
व्याख्या (हिन्दी) टाइप पनिंग ऑब्जेक्ट प्रतिनिधित्व को एक अलग प्रकार के रूप में पढ़ता है, अक्सर यूनियन या मेम्सीपी के माध्यम से, कभी-कभी पॉइंटर कास्ट के साथ अपरिभाषित व्यवहार।
🎯 Exam Perspective
OOP Using C++ ("Classes and Objects" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 29

EN + हिं
GB What is the output: class A{public: virtual void f(){cout<<'A';}}; class B:public A{public: void f()override{cout<<'B';}}; A*p=new B; p->f(); delete p;
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
B बी
AB अब
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Virtual dispatch: p is A* pointing to B object. p->f() calls B::f() via vtable. Output: B.
व्याख्या (हिन्दी) आभासी प्रेषण: p, A* है जो B ऑब्जेक्ट की ओर इशारा करता है। p->f() vtable के माध्यम से B::f() को कॉल करता है। आउटपुट: बी.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Classes and Objects" 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{public: A(){cout<<'A';} A(const A&){cout<<'C';}}; A f(){return A();} A a=f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
AC ए.सी
ACC एसीसी
AA
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) RVO/copy elision (mandatory in C++17 for prvalues) eliminates copies; only one constructor call. Output: A.
व्याख्या (हिन्दी) आरवीओ/कॉपी एलिज़न (प्रचलन के लिए C++17 में अनिवार्य) प्रतियों को समाप्त करता है; केवल एक कंस्ट्रक्टर कॉल। आउटपुट: ए.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Classes and Objects" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।