1 Question 1 EN + हिं GB What is the output: class A{public: void f(){cout<<'A';}}; class B:public A{public: void f(){cout<<'B';}}; B b; b.f(); IN आउटपुट क्या है: क्लास ए {सार्वजनिक: शून्य एफ() {काउट A A ए B B बी C AB अब D Compile error संकलन त्रुटि ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) B::f() hides A::f(). b.f() calls B's version. Output: B. व्याख्या (हिन्दी) B::f() A::f() को छुपाता है। b.f() B के संस्करण को कॉल करता है। आउटपुट: बी. 🎯 Exam Perspective OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो। 🔗 Related Questions What is 'diamond problem' in C++? What is the output: class A{public: int x=1;}; class B:... What is the output: class A{public: void f(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
2 Question 2 EN + हिं GB What is 'diamond problem' in C++? IN C++ में 'डायमंड प्रॉब्लम' क्या है? A Ambiguity when class inherits from two classes sharing a base अस्पष्टता जब वर्ग को आधार साझा करने वाले दो वर्गों से विरासत मिलती है B Memory diamond shape स्मृति हीरे का आकार C Multiple constructors एकाधिक निर्माणकर्ता D Template diamond टेम्पलेट हीरा ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Diamond problem: D inherits B and C, both inherit A. D has two copies of A unless virtual inheritance is used. व्याख्या (हिन्दी) हीरे की समस्या: D को B और C विरासत में मिले हैं, दोनों को A विरासत में मिला है। D के पास A की दो प्रतियां हैं जब तक कि आभासी विरासत का उपयोग नहीं किया जाता है। 🎯 Exam Perspective UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Inheritance" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें। 🔗 Related Questions What is 'slicing' problem? What is the output: struct B{int x=10;}; struct D:B{int... What is the output: class A{public: void f(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
3 Question 3 EN + हिं GB What is the output: class A{public: A(){cout<<'A';}}; class B:public A{public: B(){cout<<'B';}}; class C:public B{public: C(){cout<<'C';}}; C c; IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट A CBA सीबीए B ABC एबीसी C BAC बीएसी D CAB कैब ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Base classes constructed first (top-down): A then B then C. Output: ABC. व्याख्या (हिन्दी) बेस क्लास का निर्माण पहले (ऊपर से नीचे): ए, फिर बी, फिर सी। आउटपुट: एबीसी। 🎯 Exam Perspective अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें। 🔗 Related Questions What is 'protected' access specifier? What is the output: class A{public: virtual void f(){co... What is the output: class A{public: int x=1;}; class B:... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
4 Question 4 EN + हिं GB What is virtual inheritance? IN आभासी विरासत क्या है? A Ensures single base class instance in diamond inheritance हीरे की विरासत में एकल आधार वर्ग उदाहरण सुनिश्चित करता है B Virtual function inheritance वर्चुअल फ़ंक्शन इनहेरिटेंस C Pure virtual class शुद्ध आभासी कक्षा D Multiple inheritance एकाधिक वंशानुक्रम ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) virtual inheritance prevents multiple copies of base class in diamond hierarchy by sharing a single base instance. व्याख्या (हिन्दी) वर्चुअल इनहेरिटेंस एकल बेस इंस्टेंस को साझा करके डायमंड पदानुक्रम में बेस क्लास की कई प्रतियों को रोकता है। 🎯 Exam Perspective OOP Using C++ ("Inheritance" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें। 🔗 Related Questions What is the output: struct B{int x=10;}; struct D:B{int... What is 'private inheritance'? What is 'protected' access specifier? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
5 Question 5 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 &r=*new B; r.f(); IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट A A ए B B बी C AB अब D Compile error संकलन त्रुटि ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) r is reference to A but bound to B. Virtual dispatch calls B::f(). Output: B. व्याख्या (हिन्दी) r, A का संदर्भ है लेकिन B से जुड़ा है। वर्चुअल प्रेषण कॉल B::f() है। आउटपुट: बी. 🎯 Exam Perspective यह सवाल OOP Using C++ ("Inheritance" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें। 🔗 Related Questions What is 'diamond problem' in C++? What is 'private inheritance'? What is 'slicing' problem? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
6 Question 6 EN + हिं GB What is 'protected' access specifier? IN 'संरक्षित' पहुंच विनिर्देशक क्या है? A Accessible in class and derived classes only केवल कक्षा और व्युत्पन्न कक्षाओं में पहुंच योग्य B Accessible everywhere हर जगह पहुंच योग्य C Accessible only in class केवल कक्षा में ही पहुंच योग्य D Accessible in same file एक ही फ़ाइल में पहुंचयोग्य ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) protected members are accessible within the class and its derived classes, but not from outside. व्याख्या (हिन्दी) संरक्षित सदस्य वर्ग और उसके व्युत्पन्न वर्गों के भीतर पहुंच योग्य हैं, लेकिन बाहर से नहीं। 🎯 Exam Perspective यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें। 🔗 Related Questions What is the output: class A{public: void f(){cout What is 'final' keyword in C++11? What is the output: class A{public: virtual void f()=0;... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
7 Question 7 EN + हिं GB What is the output: class A{public: int x=1;}; class B:public A{public: int x=2;}; B b; cout< IN आउटपुट क्या है: class A{public: int x=1;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक: int x=2;}; बी बी; अदालत A 21 21 B 12 12 C 11 11 D Compile error संकलन त्रुटि ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) b.x refers to B::x=2. b.A::x explicitly accesses A::x=1. Output: 21. व्याख्या (हिन्दी) b.x, B::x=2 को संदर्भित करता है। b.A::x स्पष्ट रूप से A::x=1 तक पहुँचता है। आउटपुट: 21. 🎯 Exam Perspective OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो। 🔗 Related Questions What is the output: struct B{int x=10;}; struct D:B{int... What is the output: class A{public: A(){cout What is the output: class A{public: virtual void f()=0;... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
8 Question 8 EN + हिं GB What is 'private inheritance'? IN 'निजी विरासत' क्या है? A Base class public/protected members become private in derived बेस क्लास सार्वजनिक/संरक्षित सदस्य व्युत्पन्न में निजी बन जाते हैं B Inheriting private members निजी सदस्यों को विरासत में मिलाना C Preventing inheritance वंशानुक्रम को रोकना D Inheriting private functions only केवल निजी कार्य विरासत में मिले ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Private inheritance means all inherited public/protected members of base become private in the derived class. व्याख्या (हिन्दी) निजी विरासत का मतलब है कि आधार के सभी विरासत में मिले सार्वजनिक/संरक्षित सदस्य व्युत्पन्न वर्ग में निजी बन जाते हैं। 🎯 Exam Perspective SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Inheritance" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें। 🔗 Related Questions What is the output: class A{public: virtual void f(){co... What is the output: class A{public: int x=1;}; class B:... What is 'final' keyword in C++11? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
9 Question 9 EN + हिं GB What is the output: struct B{int x=10;}; struct D:B{int y=20;}; D d; cout< IN आउटपुट क्या है: struct B{int x=10;}; संरचना D:B{int y=20;}; डी डी; अदालत A 4 4 B 8 8 C 20 20 D Compile error संकलन त्रुटि ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) sizeof(D) = sizeof(B)+sizeof(D's own) = 4+4=8 (assuming int=4). व्याख्या (हिन्दी) आकार(डी) = आकार(बी)+आकार(डी का अपना) = 4+4=8 (पूर्णांक=4 मानते हुए)। 🎯 Exam Perspective अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें। 🔗 Related Questions What is the output: class A{public: void f(){cout What is the output: class A{public: int x=1;}; class B:... What is the output: class A{public: A(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
10 Question 10 EN + हिं GB What is the output: class A{public: virtual void f()=0;}; class B:public A{public: void f(){cout<<'B';}}; A *p=new B; p->f(); IN आउटपुट क्या है: क्लास ए{सार्वजनिक: वर्चुअल शून्य f()=0;}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: शून्य एफ() {काउट A A ए B B बी C Compile error संकलन त्रुटि D Undefined अपरिभाषित ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) B implements pure virtual f(). p->f() calls B::f() via vtable. Output: B. व्याख्या (हिन्दी) बी शुद्ध वर्चुअल एफ() लागू करता है। p->f() vtable के माध्यम से B::f() को कॉल करता है। आउटपुट: बी. 🎯 Exam Perspective OOP Using C++ ("Inheritance" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें। 🔗 Related Questions What is 'private inheritance'? What is the output: struct B{int x=10;}; struct D:B{int... What is the output: class A{public: void f(){cout 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
11 Question 11 EN + हिं GB What is 'slicing' problem? IN 'स्लाइसिंग' समस्या क्या है? A Derived-specific data lost when copying to base object बेस ऑब्जेक्ट पर कॉपी करते समय व्युत्पन्न-विशिष्ट डेटा खो जाता है B Memory fragmentation स्मृति विखंडन C Virtual function removal वर्चुअल फ़ंक्शन हटाना D Stack overflow स्टैक ओवरफ़्लो ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) Object slicing occurs when a derived object is assigned to a base object by value, losing the derived portion. व्याख्या (हिन्दी) ऑब्जेक्ट स्लाइसिंग तब होती है जब एक व्युत्पन्न ऑब्जेक्ट को मूल्य के आधार पर बेस ऑब्जेक्ट को सौंपा जाता है, जिससे व्युत्पन्न भाग खो जाता है। 🎯 Exam Perspective यह सवाल OOP Using C++ ("Inheritance" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें। 🔗 Related Questions What is 'protected' access specifier? What is the output: class A{public: virtual void f()=0;... What is 'covariant return type'? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
12 Question 12 EN + हिं GB What is the output: class A{public: void f(){cout<<'A';} virtual void g(){cout<<'a';}}; class B:public A{public: void f(){cout<<'B';} void g()override{cout<<'b';}}; A*p=new B; p->f(); p->g(); IN आउटपुट क्या है: क्लास ए {पब्लिक: शून्य एफ() {काउट A ABab अबाब B Ab अब C AB अब D Compile error संकलन त्रुटि ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) p->f(): non-virtual, calls A::f() (static binding) = 'A'. p->g(): virtual, calls B::g() = 'b'. Output: Ab. व्याख्या (हिन्दी) p->f(): गैर-आभासी, कॉल A::f() (स्थैतिक बाइंडिंग) = 'A'। p->g(): वर्चुअल, कॉल B::g() = 'b'। आउटपुट: एब. 🎯 Exam Perspective यह प्रश्न OOP Using C++ ("Inheritance" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें। 🔗 Related Questions What is virtual inheritance? What is the output: class A{public: A(){cout What is the output: class A{public: int x; A(int v):x(v... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
13 Question 13 EN + हिं GB What is 'final' keyword in C++11? IN C++11 में 'अंतिम' कीवर्ड क्या है? A Prevents further inheritance or overriding आगे की विरासत या ओवरराइडिंग को रोकता है B Makes class immutable कक्षा को अपरिवर्तनीय बनाता है C Equivalent to sealed सीलबंद के बराबर D Makes destructor virtual विध्वंसक को आभासी बनाता है ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) class A final{} prevents any class from inheriting A. virtual void f() final prevents overriding f. व्याख्या (हिन्दी) क्लास ए फाइनल {} किसी भी क्लास को ए इनहेरिट करने से रोकता है। वर्चुअल शून्य एफ() फाइनल एफ को ओवरराइड करने से रोकता है। 🎯 Exam Perspective OOP Using C++ ("Inheritance" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो। 🔗 Related Questions What is 'slicing' problem? What is the output: class A{public: int x; A(int v):x(v... What is 'diamond problem' in C++? 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
14 Question 14 EN + हिं GB What is the output: class A{public: int x; A(int v):x(v){}}; class B:public A{public: B():A(5){}}; B b; cout< IN आउटपुट क्या है: क्लास ए {सार्वजनिक: int x; A(int v):x(v){}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक: बी():ए(5){}}; बी बी; अदालत A 5 5 C Undefined अपरिभाषित D Compile error संकलन त्रुटि ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) B's constructor delegates to A(5), setting x=5. Output: 5. व्याख्या (हिन्दी) B का कंस्ट्रक्टर x=5 सेट करते हुए A(5) को सौंपता है। आउटपुट: 5. 🎯 Exam Perspective UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Inheritance" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें। 🔗 Related Questions What is the output: class A{public: A(){cout What is the output: class A{public: void f(){cout What is the output: struct B{int x=10;}; struct D:B{int... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)
15 Question 15 EN + हिं GB What is 'covariant return type'? IN 'सहसंयोजक रिटर्न प्रकार' क्या है? A Overriding function may return derived type of base's return type ओवरराइडिंग फ़ंक्शन आधार के रिटर्न प्रकार का व्युत्पन्न प्रकार लौटा सकता है B Returning const reference रिटर्निंग कॉन्स्ट संदर्भ C Template return type deduction टेम्प्लेट रिटर्न प्रकार कटौती D Auto return type ऑटो रिटर्न प्रकार ✅ Correct Answer: 💡 Explanation / व्याख्या Explanation (English) A virtual function override may return a pointer/reference to a derived type of the base function's return type. व्याख्या (हिन्दी) एक वर्चुअल फ़ंक्शन ओवरराइड बेस फ़ंक्शन के रिटर्न प्रकार के व्युत्पन्न प्रकार के लिए एक पॉइंटर/संदर्भ लौटा सकता है। 🎯 Exam Perspective अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Inheritance" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें। 🔗 Related Questions What is the output: struct B{int x=10;}; struct D:B{int... What is the output: class A{public: int x=1;}; class B:... What is the output: class A{public: virtual void f(){co... 📚 Related Topic Introduction to C++ (187) Variables and Data Types (160) Operators in C++ (163)