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
16
EN + हिं
GB What is 'template metaprogramming'?
IN 'टेम्पलेट मेटाप्रोग्रामिंग' क्या है?
A
Computations performed at compile time using templates टेम्प्लेट का उपयोग करके संकलन समय पर गणना की गई
B
Runtime code generation रनटाइम कोड जनरेशन
C
Code optimization कोड अनुकूलन
D
Macro programming मैक्रो प्रोग्रामिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TMP leverages template instantiation to perform computations and generate code at compile time.
व्याख्या (हिन्दी) टीएमपी गणना करने और संकलन समय पर कोड उत्पन्न करने के लिए टेम्पलेट इंस्टेंटेशन का लाभ उठाता है।
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; अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) enable_if::type = int. x=5. Output: 5.
व्याख्या (हिन्दी) Enable_if::type = int. एक्स=5. आउटपुट: 5.
18
EN + हिं
GB What is 'fold expression' in C++17?
IN C++17 में 'फोल्ड एक्सप्रेशन' क्या है?
A
Applying binary operator over parameter pack पैरामीटर पैक पर बाइनरी ऑपरेटर लागू करना
B
Folding function calls फ़ोल्डिंग फ़ंक्शन कॉल
C
Template recursion टेम्पलेट पुनरावर्तन
D
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 तक विस्तारित होता है।
19
EN + हिं
GB What is the output: template int sum(Args... args){return (args+...);} cout<
IN आउटपुट क्या है: टेम्पलेट int sum(Args... args){return (args+...);} cout
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (args+...) fold: 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) (तर्क+...) गुना: 1+2+3+4+5=15। आउटपुट: 15.
20
EN + हिं
GB What is 'type trait' in C++?
IN C++ में 'प्रकार विशेषता' क्या है?
A
Compile-time type information query संकलन-समय प्रकार की जानकारी क्वेरी
B
Runtime type checking रनटाइम प्रकार की जाँच
C
Type conversion function रूपांतरण फ़ंक्शन टाइप करें
D
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) प्रकारों के बारे में संकलन-समय की जानकारी प्रदान करते हैं।
21
EN + हिं
GB What is the output: cout<::value<::value;
IN आउटपुट क्या है: cout
A
10 10
B
01 01
C
11 11
D
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.
22
EN + हिं
GB What is 'CRTP' and static polymorphism?
IN 'सीआरटीपी' और स्थैतिक बहुरूपता क्या है?
A
Base<Derived> pattern enabling compile-time polymorphism संकलन-समय बहुरूपता को सक्षम करने वाला आधार पैटर्न
B
Runtime vtable रनटाइम वीटेबल
C
Template specialization only केवल टेम्पलेट विशेषज्ञता
D
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.
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";}}; अदालत
A
intunknown अनजान
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
unknownint अज्ञात
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TypeName specialized: 'int'. TypeName generic: 'unknown'. Output: intunknown.
व्याख्या (हिन्दी) विशेष प्रकार का नाम: 'int'। सामान्य नाम टाइप करें: 'अज्ञात'। आउटपुट: अज्ञात.
24
EN + हिं
GB What is the output: template struct Array{T data[N]; int size(){return N;}}; Array a; cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर ऐरे {टी डेटा [एन]; पूर्णांक आकार(){वापसी एन;}}; सरणी ए; अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) N=5 is non-type template parameter. size() returns N=5. Output: 5.
व्याख्या (हिन्दी) N=5 गैर-प्रकार टेम्पलेट पैरामीटर है। आकार() एन=5 लौटाता है। आउटपुट: 5.
25
EN + हिं
GB What is 'class template' vs 'function template'?
IN 'क्लास टेम्प्लेट' बनाम 'फ़ंक्शन टेम्प्लेट' क्या है?
A
Class template: parameterized class; function template: parameterized function क्लास टेम्प्लेट: पैरामीटरयुक्त क्लास; फ़ंक्शन टेम्पलेट: पैरामीटरयुक्त फ़ंक्शन
B
No difference कोई फर्क नहीं
C
Class templates need explicit specialization क्लास टेम्प्लेट को स्पष्ट विशेषज्ञता की आवश्यकता होती है
D
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.
व्याख्या (हिन्दी) क्लास टेम्प्लेट कक्षाओं के एक परिवार को परिभाषित करते हैं; फ़ंक्शन टेम्प्लेट फ़ंक्शंस के एक परिवार को परिभाषित करते हैं। दोनों विशेषज्ञता का समर्थन करते हैं।
26
EN + हिं
GB What is the output: template auto wrap(T t){return [t](){return t;};} auto f=wrap(42); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो रैप (टी टी) {रिटर्न [टी]() {रिटर्न टी;};} ऑटो एफ = रैप (42); अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) wrap(42) returns lambda capturing t=42. f()=42. Output: 42.
व्याख्या (हिन्दी) रैप(42) टी=42 कैप्चरिंग वाला लैम्ब्डा लौटाता है। एफ()=42. आउटपुट: 42.
27
EN + हिं
GB What is 'deduction guide' in C++17?
IN C++17 में 'डिडक्शन गाइड' क्या है?
A
Explicit rules for class template argument deduction वर्ग टेम्पलेट तर्क कटौती के लिए स्पष्ट नियम
B
Automatic template deduction rule स्वचालित टेम्पलेट कटौती नियम
C
Type alias guide उपनाम गाइड टाइप करें
D
Concept guide संकल्पना मार्गदर्शिका
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Deduction guides specify how CTAD should deduce template arguments: Pair(T,U)->Pair;
व्याख्या (हिन्दी) कटौती गाइड निर्दिष्ट करते हैं कि CTAD को टेम्पलेट तर्क कैसे निकालना चाहिए: जोड़ी (टी, यू) -> जोड़ी;
28
EN + हिं
GB What is the output: template constexpr T pi=T(3.1415926535); cout<<<' '<;
IN आउटपुट क्या है: टेम्पलेट constexpr T pi=T(3.1415926535); अदालत
A
3 3.14159 3 3.14159
B
3.14159 3 3.14159 3
C
Compile error संकलन त्रुटि
D
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.
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
A
RL आर एल
B
LR एलआर
C
RR आरआर
D
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।
30
EN + हिं
GB What is 'explicit instantiation' of templates?
IN टेम्प्लेट की 'स्पष्ट तात्कालिकता' क्या है?
A
Forcing compiler to instantiate specific template specialization कंपाइलर को विशिष्ट टेम्पलेट विशेषज्ञता को तुरंत चालू करने के लिए मजबूर करना
B
Implicit instantiation निहित तात्कालिकता
C
Template inheritance टेम्पलेट विरासत
D
SFINAE bypass SFINAE बाईपास
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) template class std::vector; forces instantiation in that translation unit, useful for reducing compile times.
व्याख्या (हिन्दी) टेम्पलेट क्लास std::वेक्टर; उस अनुवाद इकाई में तात्कालिकता को बल देता है, जो संकलन समय को कम करने के लिए उपयोगी है।
16–30 of 131