OOP Using C++ — MCQ Practice

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

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

Question 16

EN + हिं
GB What is 'template metaprogramming'?
IN 'टेम्पलेट मेटाप्रोग्रामिंग' क्या है?
Computations performed at compile time using templates टेम्प्लेट का उपयोग करके संकलन समय पर गणना की गई
Runtime code generation रनटाइम कोड जनरेशन
Code optimization कोड अनुकूलन
Macro programming मैक्रो प्रोग्रामिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TMP leverages template instantiation to perform computations and generate code at compile time.
व्याख्या (हिन्दी) टीएमपी गणना करने और संकलन समय पर कोड उत्पन्न करने के लिए टेम्पलेट इंस्टेंटेशन का लाभ उठाता है।
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 17

EN + हिं
GB What is the output: template struct enable_if{}; template struct enable_if{typedef T type;}; enable_if::type x=5; cout<
IN आउटपुट क्या है: टेम्पलेट struct Enable_if{}; टेम्पलेट संरचना Enable_if{typedef T type;}; Enable_if::प्रकार x=5; अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) enable_if::type = int. x=5. Output: 5.
व्याख्या (हिन्दी) Enable_if::type = int. एक्स=5. आउटपुट: 5.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 18

EN + हिं
GB What is 'fold expression' in C++17?
IN C++17 में 'फोल्ड एक्सप्रेशन' क्या है?
Applying binary operator over parameter pack पैरामीटर पैक पर बाइनरी ऑपरेटर लागू करना
Folding function calls फ़ोल्डिंग फ़ंक्शन कॉल
Template recursion टेम्पलेट पुनरावर्तन
Variadic macro विविध स्थूल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fold expressions: (args + ...) expands to arg1+arg2+...+argN at compile time for variadic templates.
व्याख्या (हिन्दी) फ़ोल्ड एक्सप्रेशन: (args + ...) विविध टेम्पलेट्स के लिए संकलन समय पर arg1+arg2+...+argN तक विस्तारित होता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 19

EN + हिं
GB What is the output: template int sum(Args... args){return (args+...);} cout<
IN आउटपुट क्या है: टेम्पलेट int sum(Args... args){return (args+...);} cout
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (args+...) fold: 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) (तर्क+...) गुना: 1+2+3+4+5=15। आउटपुट: 15.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 20

EN + हिं
GB What is 'type trait' in C++?
IN C++ में 'प्रकार विशेषता' क्या है?
Compile-time type information query संकलन-समय प्रकार की जानकारी क्वेरी
Runtime type checking रनटाइम प्रकार की जाँच
Type conversion function रूपांतरण फ़ंक्शन टाइप करें
A template alias एक टेम्पलेट उपनाम
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Type traits (std::is_integral, std::is_pointer) provide compile-time information about types.
व्याख्या (हिन्दी) प्रकार लक्षण (std::is_integral, std::is_pointer) प्रकारों के बारे में संकलन-समय की जानकारी प्रदान करते हैं।
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 21

EN + हिं
GB What is the output: cout<::value<::value;
IN आउटपुट क्या है: cout
10 10
01 01
11 11
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) is_same::value=true=1; is_same::value=false=0. Output: 10.
व्याख्या (हिन्दी) is_same::value=true=1; is_same::value=false=0. आउटपुट: 10.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 22

EN + हिं
GB What is 'CRTP' and static polymorphism?
IN 'सीआरटीपी' और स्थैतिक बहुरूपता क्या है?
Base<Derived> pattern enabling compile-time polymorphism संकलन-समय बहुरूपता को सक्षम करने वाला आधार पैटर्न
Runtime vtable रनटाइम वीटेबल
Template specialization only केवल टेम्पलेट विशेषज्ञता
Meta-object protocol मेटा-ऑब्जेक्ट प्रोटोकॉल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) CRTP: template class Base{void interface(){static_cast(this)->impl();}}; enables static dispatch.
व्याख्या (हिन्दी) सीआरटीपी: टेम्प्लेट क्लास बेस{void इंटरफ़ेस(){static_cast(this)->impl();}}; enables static dispatch.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 23

EN + हिं
GB What is the output: template struct TypeName{static const char* name(){return "unknown";}}; template<> struct TypeName{static const char* name(){return "int";}}; cout<::name()<::name();
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर टाइपनेम{स्टैटिक कॉन्स्ट चार* नेम(){रिटर्न "अज्ञात";}}; टेम्प्लेट संरचना प्रकारनाम{स्थैतिक स्थिरांक चार* नाम(){वापसी "int";}}; अदालत
intunknown अनजान
Compile error संकलन त्रुटि
Undefined अपरिभाषित
unknownint अज्ञात
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TypeName specialized: 'int'. TypeName generic: 'unknown'. Output: intunknown.
व्याख्या (हिन्दी) विशेष प्रकार का नाम: 'int'। सामान्य नाम टाइप करें: 'अज्ञात'। आउटपुट: अज्ञात.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 24

EN + हिं
GB What is the output: template struct Array{T data[N]; int size(){return N;}}; Array a; cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर ऐरे {टी डेटा [एन]; पूर्णांक आकार(){वापसी एन;}}; सरणी ए; अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) N=5 is non-type template parameter. size() returns N=5. Output: 5.
व्याख्या (हिन्दी) N=5 गैर-प्रकार टेम्पलेट पैरामीटर है। आकार() एन=5 लौटाता है। आउटपुट: 5.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 25

EN + हिं
GB What is 'class template' vs 'function template'?
IN 'क्लास टेम्प्लेट' बनाम 'फ़ंक्शन टेम्प्लेट' क्या है?
Class template: parameterized class; function template: parameterized function क्लास टेम्प्लेट: पैरामीटरयुक्त क्लास; फ़ंक्शन टेम्पलेट: पैरामीटरयुक्त फ़ंक्शन
No difference कोई फर्क नहीं
Class templates need explicit specialization क्लास टेम्प्लेट को स्पष्ट विशेषज्ञता की आवश्यकता होती है
Function templates cannot be specialized फ़ंक्शन टेम्प्लेट विशिष्ट नहीं किए जा सकते
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Class templates define a family of classes; function templates define a family of functions. Both support specialization.
व्याख्या (हिन्दी) क्लास टेम्प्लेट कक्षाओं के एक परिवार को परिभाषित करते हैं; फ़ंक्शन टेम्प्लेट फ़ंक्शंस के एक परिवार को परिभाषित करते हैं। दोनों विशेषज्ञता का समर्थन करते हैं।
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 26

EN + हिं
GB What is the output: template auto wrap(T t){return [t](){return t;};} auto f=wrap(42); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो रैप (टी टी) {रिटर्न [टी]() {रिटर्न टी;};} ऑटो एफ = रैप (42); अदालत
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) wrap(42) returns lambda capturing t=42. f()=42. Output: 42.
व्याख्या (हिन्दी) रैप(42) टी=42 कैप्चरिंग वाला लैम्ब्डा लौटाता है। एफ()=42. आउटपुट: 42.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 27

EN + हिं
GB What is 'deduction guide' in C++17?
IN C++17 में 'डिडक्शन गाइड' क्या है?
Explicit rules for class template argument deduction वर्ग टेम्पलेट तर्क कटौती के लिए स्पष्ट नियम
Automatic template deduction rule स्वचालित टेम्पलेट कटौती नियम
Type alias guide उपनाम गाइड टाइप करें
Concept guide संकल्पना मार्गदर्शिका
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Deduction guides specify how CTAD should deduce template arguments: Pair(T,U)->Pair;
व्याख्या (हिन्दी) कटौती गाइड निर्दिष्ट करते हैं कि CTAD को टेम्पलेट तर्क कैसे निकालना चाहिए: जोड़ी (टी, यू) -> जोड़ी;
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 28

EN + हिं
GB What is the output: template constexpr T pi=T(3.1415926535); cout<<<' '<;
IN आउटपुट क्या है: टेम्पलेट constexpr T pi=T(3.1415926535); अदालत
3 3.14159 3 3.14159
3.14159 3 3.14159 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) pi=3 (truncated), pi=3.14159 (default precision). Output: 3 3.14159.
व्याख्या (हिन्दी) pi=3 (छोटा), pi=3.14159 (डिफ़ॉल्ट परिशुद्धता)। आउटपुट: 3 3.14159.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 29

EN + हिं
GB What is the output: template void f(T&&){cout<<'R';} template void f(const T&){cout<<'L';} int x=5; f(x); f(5);
IN आउटपुट क्या है: टेम्पलेट शून्य f(T&&){cout
RL आर एल
LR एलआर
RR आरआर
LL डालूँगा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(x): x is lvalue, deduced as f(int&) which is f(T&&) with T=int& (universal ref wins for lvalue by exact match...actually const T& matches lvalue; T&& as universal ref also matches. Both viable; T&& is less specialized for lvalue...this is complex. The const T& overload is preferred for lvalue. f(5): rvalue matches T&& perfectly. Output: LR.
व्याख्या (हिन्दी) f(x): x एक lvalue है, जिसे f(int&) के रूप में निकाला जाता है जो कि f(T&&) है, T=int& के साथ (सार्वभौमिक रेफरी सटीक मिलान द्वारा lvalue के लिए जीतता है...वास्तव में const T& lvalue से मेल खाता है; T&& सार्वभौमिक रेफरी के रूप में भी मेल खाता है। दोनों व्यवहार्य; T&& lvalue के लिए कम विशिष्ट है...यह जटिल है। lvalue के लिए const T& अधिभार को प्राथमिकता दी जाती है। f(5): rvalue T&& से पूरी तरह मेल खाता है। आउटपुट: LR।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 30

EN + हिं
GB What is 'explicit instantiation' of templates?
IN टेम्प्लेट की 'स्पष्ट तात्कालिकता' क्या है?
Forcing compiler to instantiate specific template specialization कंपाइलर को विशिष्ट टेम्पलेट विशेषज्ञता को तुरंत चालू करने के लिए मजबूर करना
Implicit instantiation निहित तात्कालिकता
Template inheritance टेम्पलेट विरासत
SFINAE bypass SFINAE बाईपास
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) template class std::vector; forces instantiation in that translation unit, useful for reducing compile times.
व्याख्या (हिन्दी) टेम्पलेट क्लास std::वेक्टर; उस अनुवाद इकाई में तात्कालिकता को बल देता है, जो संकलन समय को कम करने के लिए उपयोगी है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।