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 1

EN + हिं
GB What is the output: template T add(T a,T b){return a+b;} cout<
IN आउटपुट क्या है: टेम्प्लेट टी ऐड(टी ए,टी बी){रिटर्न ए+बी;} कॉउट
7 4 7 4
7 4.0 7 4.0
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) add(3,4)=7, add(1.5,2.5)=4.0. Output: 7 4.
व्याख्या (हिन्दी) जोड़(3,4)=7, जोड़(1.5,2.5)=4.0। आउटपुट: 7 4.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 2

EN + हिं
GB What is 'template argument deduction'?
IN 'टेम्पलेट तर्क कटौती' क्या है?
Compiler deduces template type from function call arguments कंपाइलर फ़ंक्शन कॉल तर्कों से टेम्पलेट प्रकार का अनुमान लगाता है
Specifying template args explicitly टेम्पलेट तर्कों को स्पष्ट रूप से निर्दिष्ट करना
Runtime type deduction रनटाइम प्रकार की कटौती
SFINAE SFINAE
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Template argument deduction: the compiler infers T from the argument types when calling a function template.
व्याख्या (हिन्दी) टेम्प्लेट तर्क कटौती: फ़ंक्शन टेम्प्लेट को कॉल करते समय कंपाइलर तर्क प्रकारों से टी का अनुमान लगाता है।
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 3

EN + हिं
GB What is the output: template int f(){return N*N;} cout<();
IN आउटपुट क्या है: टेम्पलेट int f(){return N*N;} cout
25 25
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) N=5 at compile time. f<5>()=5*5=25. Output: 25.
व्याख्या (हिन्दी) संकलन समय पर N=5. एफ()=5*5=25. Output: 25.
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 4

EN + हिं
GB What is 'template specialization'?
IN 'टेम्पलेट विशेषज्ञता' क्या है?
Providing specific implementation for particular template argument विशेष टेम्पलेट तर्क के लिए विशिष्ट कार्यान्वयन प्रदान करना
Overloading templates टेम्प्लेट ओवरलोड हो रहे हैं
Runtime template selection रनटाइम टेम्पलेट चयन
Template inheritance टेम्पलेट विरासत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Explicit specialization: template<> void f(){} provides custom implementation for T=int.
व्याख्या (हिन्दी) स्पष्ट विशेषज्ञता: टेम्पलेट void f(){} T=int के लिए कस्टम कार्यान्वयन प्रदान करता है।
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 5

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

Question 6

EN + हिं
GB What is 'variadic template'?
IN 'वेरिएडिक टेम्प्लेट' क्या है?
Template with variable number of parameters using ... ... का उपयोग करके पैरामीटरों की परिवर्तनीय संख्या वाला टेम्पलेट
Template with default args डिफ़ॉल्ट तर्क के साथ टेम्पलेट
Recursive template पुनरावर्ती टेम्पलेट
Template overloading टेम्प्लेट ओवरलोडिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) template accepts zero or more type parameters; Args... is the parameter pack.
व्याख्या (हिन्दी) टेम्पलेट शून्य या अधिक प्रकार के पैरामीटर स्वीकार करता है; Args... is the parameter pack.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 7

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

Question 8

EN + हिं
GB What is 'SFINAE' and enable_if?
IN 'SFINAE' और Enable_if क्या है?
Conditionally enabling function template overloads based on type traits प्रकार लक्षणों के आधार पर फ़ंक्शन टेम्पलेट ओवरलोड को सशर्त रूप से सक्षम करना
Runtime type checking रनटाइम प्रकार की जाँच
Exception handling एक्सेप्शन हेंडलिंग
Virtual function selection आभासी फ़ंक्शन चयन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::enable_if::type SFINAE-disables template if condition is false.
व्याख्या (हिन्दी) std::enable_if::type SFINAE-यदि शर्त गलत है तो टेम्पलेट अक्षम हो जाता है।
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 9

EN + हिं
GB What is the output: template void f(T){cout<<'G';} template<> void f(int){cout<<'S';} f(3); f(3.0);
IN आउटपुट क्या है: टेम्पलेट शून्य f(T){cout
SG एसजी
GG जीजी
Compile error संकलन त्रुटि
GS जी एस
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(3): T=int, explicit specialization: 'S'. f(3.0): T=double, generic: 'G'. Output: SG.
व्याख्या (हिन्दी) एफ(3): टी=इंट, स्पष्ट विशेषज्ञता: 'एस'। एफ(3.0): टी=डबल, जेनेरिक: 'जी'। आउटपुट: एसजी.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 10

EN + हिं
GB What is 'template template parameter'?
IN 'टेम्पलेट टेम्प्लेट पैरामीटर' क्या है?
Parameter that is itself a template पैरामीटर जो स्वयं एक टेम्पलेट है
Template with type and non-type params प्रकार और गैर-प्रकार के पैरामीटर वाला टेम्पलेट
Nested template class नेस्टेड टेम्पलेट क्लास
Template inheritance टेम्पलेट विरासत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) template class Container> — Container itself is a template (e.g., std::vector).
व्याख्या (हिन्दी) टेम्पलेट - कंटेनर स्वयं एक टेम्पलेट है (उदाहरण के लिए, std::vector)।
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 11

EN + हिं
GB What is the output: template struct Fib{static const int v=Fib::v+Fib::v;}; template<> struct Fib<0>{static const int v=0;}; template<> struct Fib<1>{static const int v=1;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट struct Fib{static const int v=Fib::v+Fib::v;}; टेम्प्लेट संरचना Fib{static const int v=0;}; टेम्प्लेट संरचना Fib{static const int v=1;}; अदालत
13 13
8 8
21 21
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fib sequence: 0,1,1,2,3,5,8,13. Fib<7>=13. Output: 13.
व्याख्या (हिन्दी) फाइब अनुक्रम: 0,1,1,2,3,5,8,13। फ़िब=13. आउटपुट: 13.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 12

EN + हिं
GB What is 'concept' constraint in C++20?
IN C++20 में 'अवधारणा' बाधा क्या है?
template<std::integral T> — constrains T to integral types टेम्पलेट - टी को अभिन्न प्रकारों तक सीमित करता है
A virtual base class एक वर्चुअल बेस क्लास
A typedef एक टाइपडिफ़
A runtime check एक रनटाइम जांच
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Concepts constrain template parameters: template void f(T); only accepts integral types.
व्याख्या (हिन्दी) अवधारणाएँ टेम्प्लेट पैरामीटर्स को बाधित करती हैं: टेम्प्लेट शून्य f(T); केवल अभिन्न प्रकार स्वीकार करता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 13

EN + हिं
GB What is the output: template class A{public: static int c; A(){c++;}}; template int A::c=0; A a,b; A d; cout<::c<::c;
IN आउटपुट क्या है: टेम्प्लेट क्लास ए {पब्लिक: स्टेटिक इंट सी; ए(){सी++;}}; template int A::c=0; ए ए, बी; ए डी; अदालत
21 21
12 12
11 11
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A and A are different instantiations with separate static c. Two A objects: c=2. One A: c=1. Output: 21.
व्याख्या (हिन्दी) ए और ए अलग-अलग स्थैतिक सी के साथ अलग-अलग तात्कालिकताएं हैं। दो A वस्तुएँ: c=2. एक ए: सी=1. आउटपुट: 21.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 14

EN + हिं
GB What is 'parameter pack expansion'?
IN 'पैरामीटर पैक विस्तार' क्या है?
Using ... to expand variadic template parameters विविध टेम्पलेट पैरामीटरों का विस्तार करने के लिए ... का उपयोग करना
Loop over template args टेम्प्लेट आर्ग पर लूप करें
Runtime variadic args रनटाइम विविध तर्क
printf-style args प्रिंटफ-शैली तर्क
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Args... expands to T1, T2, ... in template context; used for forwarding, tuple construction, etc.
व्याख्या (हिन्दी) Args... टेम्पलेट संदर्भ में T1, T2, ... तक विस्तारित होता है; used for forwarding, tuple construction, etc.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 15

EN + हिं
GB What is the output: template T max(T a,T b){return a>b?a:b;} cout<(3,4.5);
IN आउटपुट क्या है: टेम्पलेट T max(T a,T b){return a>b?a:b;} cout
4.5 4.5
4 4
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) T explicitly specified as double; 3 converts to 3.0. max(3.0,4.5)=4.5. Output: 4.5.
व्याख्या (हिन्दी) टी को स्पष्ट रूप से डबल के रूप में निर्दिष्ट किया गया है; 3 को 3.0 में परिवर्तित करता है। अधिकतम(3.0,4.5)=4.5. आउटपुट: 4.5.
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।