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{public: A(){x=++c;} static int c; int x;}; int A::c=0; A a,b,c; cout<
IN आउटपुट क्या है: class A{public: A(){x=++c;} static int c; int x;}; int A::c=0; ए ए, बी, सी; अदालत
123 123
321 321
111 111
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Each constructor increments static c: a.x=1, b.x=2, c.x=3. Output: 123.
व्याख्या (हिन्दी) प्रत्येक कंस्ट्रक्टर स्थिर c बढ़ाता है: a.x=1, b.x=2, c.x=3। आउटपुट: 123.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 17

EN + हिं
GB What is a 'converting constructor'?
IN 'कन्वर्टिंग कंस्ट्रक्टर' क्या है?
Constructor enabling implicit type conversion अंतर्निहित प्रकार के रूपांतरण को सक्षम करने वाला कंस्ट्रक्टर
Constructor for type casting टाइप कास्टिंग के लिए कंस्ट्रक्टर
Explicit constructor स्पष्ट निर्माता
Copy constructor कंस्ट्रक्टर कॉपी करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A constructor callable with a single argument that enables implicit conversion from that argument type to the class type.
व्याख्या (हिन्दी) एकल तर्क के साथ कॉल करने योग्य एक कंस्ट्रक्टर जो उस तर्क प्रकार से क्लास प्रकार में अंतर्निहित रूपांतरण को सक्षम बनाता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 18

EN + हिं
GB What is the output: class A{public: ~A(){cout<<'X';}}; A *p=new A[3]; delete[] p;
IN आउटपुट क्या है: क्लास ए {सार्वजनिक: ~ ए() {काउट
X एक्स
XXX XXX
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) delete[] calls destructor for each of 3 elements. Output: XXX.
व्याख्या (हिन्दी) delete[] प्रत्येक 3 तत्वों के लिए डिस्ट्रक्टर को कॉल करता है। आउटपुट: XXX.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 19

EN + हिं
GB What happens if constructor throws an exception?
IN यदि कंस्ट्रक्टर अपवाद फेंकता है तो क्या होता है?
Object is partially constructed; destructor NOT called वस्तु आंशिक रूप से निर्मित है; विध्वंसक को नहीं बुलाया गया
Destructor is called संहारक कहा जाता है
Program terminates कार्यक्रम समाप्त
Exception is suppressed अपवाद दबा दिया गया है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) If constructor throws, the object is not fully constructed so its destructor is not called. Already-initialized member destructors are called.
व्याख्या (हिन्दी) यदि कंस्ट्रक्टर थ्रो करता है, तो ऑब्जेक्ट पूरी तरह से निर्मित नहीं होता है इसलिए उसके डिस्ट्रक्टर को नहीं बुलाया जाता है। पहले से आरंभ किए गए सदस्य विध्वंसक कहलाते हैं।
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 20

EN + हिं
GB What is the output: class A{public: A(int x){cout<
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए (इंट एक्स) {काउट
5C 5सी
5 5
CC सीसी
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) obj(5): prints 5. f(obj): passes by value, copy constructor called, prints C. Output: 5C.
व्याख्या (हिन्दी) obj(5): प्रिंट 5. f(obj): मान से गुजरता है, कॉपी कंस्ट्रक्टर को बुलाया जाता है, C प्रिंट करता है। आउटपुट: 5C।
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 21

EN + हिं
GB What is 'move constructor'?
IN 'मूव कंस्ट्रक्टर' क्या है?
Constructor transferring resources from rvalue कंस्ट्रक्टर प्रतिद्वंद्विता से संसाधनों को स्थानांतरित कर रहा है
Copy constructor कंस्ट्रक्टर कॉपी करें
Default constructor डिफ़ॉल्ट कंस्ट्रक्टर
Delegating constructor प्रतिनिधि निर्माणकर्ता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Move constructor A(A&&) steals resources from a temporary (rvalue) instead of copying them.
व्याख्या (हिन्दी) मूव कंस्ट्रक्टर A(A&&) संसाधनों को कॉपी करने के बजाय अस्थायी (प्रतिद्वंद्विता) से चुराता है।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 22

EN + हिं
GB What is the output: class A{public: A(){cout<<'N';} A(int){cout<<'I';} A(double){cout<<'D';}}; A a(1), b(1.0), c;
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
IDA आईडीए
IDN आईडीएन
NID एनआईडी
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a(1): int ctor=I. b(1.0): double ctor=D. c: default ctor=N. Output: IDN.
व्याख्या (हिन्दी) a(1): int ctor=I. b(1.0): डबल ctor=D. सी: डिफ़ॉल्ट ctor=N. आउटपुट: आईडीएन.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 23

EN + हिं
GB What is the output: class A{public: int x=0; A()=default;}; A a{}; cout<
IN आउटपुट क्या है: class A{public: int x=0; ए()=डिफ़ॉल्ट;}; ए ए{}; अदालत
Undefined अपरिभाषित
1 1
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default constructor with in-class initializer: x=0. Output: 0.
व्याख्या (हिन्दी) इन-क्लास इनिशियलाइज़र के साथ डिफ़ॉल्ट कंस्ट्रक्टर: x=0। आउटपुट: 0.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 24

EN + हिं
GB What is 'Rule of Five' in C++11?
IN C++11 में 'पांच का नियम' क्या है?
Define all 5: destructor, copy-ctor, copy-assign, move-ctor, move-assign सभी 5 को परिभाषित करें: डिस्ट्रक्टर, कॉपी-क्टर, कॉपी-असाइन, मूव-क्टर, मूव-असाइन
5 virtual functions 5 आभासी कार्य
5 inheritance levels 5 वंशानुक्रम स्तर
5 constructors 5 कंस्ट्रक्टर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Rule of Five extends Rule of Three with move constructor and move assignment operator for C++11.
व्याख्या (हिन्दी) पाँच का नियम C++11 के लिए मूव कंस्ट्रक्टर और मूव असाइनमेंट ऑपरेटर के साथ तीन के नियम का विस्तार करता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 25

EN + हिं
GB What is the output: class A{public: A(){cout<<'B';} ~A(){cout<<'E';} void f(){cout<<'M';}}; A a; a.f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
BME बीएमई
BEM कार्यलय
Compile error संकलन त्रुटि
BE होना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Constructor prints B, f() prints M, destructor prints E at end of scope. Output: BME.
व्याख्या (हिन्दी) कंस्ट्रक्टर बी प्रिंट करता है, एफ() प्रिंट एम, डिस्ट्रक्टर स्कोप के अंत में ई प्रिंट करता है। आउटपुट: बीएमई.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 26

EN + हिं
GB When are destructors called in reverse order?
IN विध्वंसकों को उल्टे क्रम में कब बुलाया जाता है?
For objects declared in same scope समान दायरे में घोषित वस्तुओं के लिए
For base and derived classes आधार और व्युत्पन्न वर्गों के लिए
For array elements सरणी तत्वों के लिए
All of the above ऊपर के सभी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Destructors are called in reverse order of construction for objects in the same scope, array elements (reverse index), and derived/base class (derived first).
व्याख्या (हिन्दी) विनाशकों को समान दायरे, सरणी तत्वों (रिवर्स इंडेक्स), और व्युत्पन्न/आधार वर्ग (पहले व्युत्पन्न) में वस्तुओं के लिए निर्माण के विपरीत क्रम में बुलाया जाता है।
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Constructors and Destructors" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 27

EN + हिं
GB What is the output: class A{int x; public: explicit A(int v):x(v){} int get()const{return x;}}; A a=A(5); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: स्पष्ट A(int v):x(v){} int get()const{return x;}}; ए ए=ए(5); अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(5) is direct initialization; explicit prevents implicit conversion but direct is fine. a.get()=5.
व्याख्या (हिन्दी) ए(5) प्रत्यक्ष आरंभीकरण है; स्पष्ट रूप से अंतर्निहित रूपांतरण को रोकता है लेकिन प्रत्यक्ष ठीक है। a.get()=5.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Constructors and Destructors" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 28

EN + हिं
GB What is the output: class A{public: A(int x=10,int y=20){cout<
IN आउटपुट क्या है: वर्ग A{सार्वजनिक: A(int x=10,int y=20){cout
303011 303011
302511 302511
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a: 10+20=30, b(5): 5+20=25, c(5,6): 5+6=11. Output: 302511.
व्याख्या (हिन्दी) ए: 10+20=30, बी(5): 5+20=25, सी(5,6): 5+6=11। आउटपुट: 302511.
🎯 Exam Perspective
OOP Using C++ ("Constructors and Destructors" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 29

EN + हिं
GB What is the output: class A{public: ~A()=delete;}; {A a;}
IN आउटपुट क्या है: क्लास ए{सार्वजनिक: ~ए()=डिलीट;}; {ए ए;}
Compile error संकलन त्रुटि
Undefined अपरिभाषित
A
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Deleting destructor prevents any object with automatic storage duration; compile error.
व्याख्या (हिन्दी) विध्वंसक को हटाने से स्वचालित भंडारण अवधि वाली किसी भी वस्तु को रोका जा सकता है; संकलन त्रुटि.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Constructors and Destructors" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 30

EN + हिं
GB What is 'trivial destructor'?
IN 'तुच्छ विध्वंसक' क्या है?
Destructor that does nothing and is compiler-generated डिस्ट्रक्टर जो कुछ नहीं करता है और कंपाइलर-जनरेटेड है
Empty user-defined destructor उपयोगकर्ता-परिभाषित विध्वंसक को खाली करें
Virtual destructor आभासी विध्वंसक
Static destructor स्थैतिक विध्वंसक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A trivial destructor is implicitly defined, does nothing, and allows objects to be destroyed without calling it (e.g., via free()).
व्याख्या (हिन्दी) एक तुच्छ विध्वंसक को स्पष्ट रूप से परिभाषित किया गया है, कुछ भी नहीं करता है, और वस्तुओं को बिना कॉल किए नष्ट करने की अनुमति देता है (उदाहरण के लिए, free() के माध्यम से)।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Constructors and Destructors" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।