OOP Using C++ — MCQ Practice

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

📚 1915 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
1915 questions
436
EN + हिं
GB What is the output: template struct Box{T val; Box(T v):val(v){}}; Box b(42); cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर बॉक्स {टी वैल; बॉक्स(टी वी):वैल(वी){}}; बॉक्स बी(42); अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
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.
437
EN + हिं
GB What is 'variadic template'?
IN 'वेरिएडिक टेम्प्लेट' क्या है?
A
Template with variable number of parameters using ... ... का उपयोग करके पैरामीटरों की परिवर्तनीय संख्या वाला टेम्पलेट
B
Template with default args डिफ़ॉल्ट तर्क के साथ टेम्पलेट
C
Recursive template पुनरावर्ती टेम्पलेट
D
Template overloading टेम्प्लेट ओवरलोडिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) template accepts zero or more type parameters; Args... is the parameter pack.
व्याख्या (हिन्दी) टेम्पलेट शून्य या अधिक प्रकार के पैरामीटर स्वीकार करता है; Args... is the parameter pack.
438
EN + हिं
GB What is the output: template auto add(T a,U b)->decltype(a+b){return a+b;} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ऐड(टी ए,यू बी)->डिक्लटाइप(ए+बी){रिटर्न ए+बी;} कॉउट
A
3.5 3.5
B
3 3
C
Compile error संकलन त्रुटि
D
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.
439
EN + हिं
GB What is 'SFINAE' and enable_if?
IN 'SFINAE' और Enable_if क्या है?
A
Conditionally enabling function template overloads based on type traits प्रकार लक्षणों के आधार पर फ़ंक्शन टेम्पलेट ओवरलोड को सशर्त रूप से सक्षम करना
B
Runtime type checking रनटाइम प्रकार की जाँच
C
Exception handling एक्सेप्शन हेंडलिंग
D
Virtual function selection आभासी फ़ंक्शन चयन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::enable_if::type SFINAE-disables template if condition is false.
व्याख्या (हिन्दी) std::enable_if::type SFINAE-यदि शर्त गलत है तो टेम्पलेट अक्षम हो जाता है।
440
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
A
SG एसजी
B
GG जीजी
C
Compile error संकलन त्रुटि
D
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): टी=डबल, जेनेरिक: 'जी'। आउटपुट: एसजी.
441
EN + हिं
GB What is 'template template parameter'?
IN 'टेम्पलेट टेम्प्लेट पैरामीटर' क्या है?
A
Parameter that is itself a template पैरामीटर जो स्वयं एक टेम्पलेट है
B
Template with type and non-type params प्रकार और गैर-प्रकार के पैरामीटर वाला टेम्पलेट
C
Nested template class नेस्टेड टेम्पलेट क्लास
D
Template inheritance टेम्पलेट विरासत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) template class Container> — Container itself is a template (e.g., std::vector).
व्याख्या (हिन्दी) टेम्पलेट - कंटेनर स्वयं एक टेम्पलेट है (उदाहरण के लिए, std::vector)।
442
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;}; अदालत
A
13 13
B
8 8
C
21 21
D
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.
443
EN + हिं
GB What is 'concept' constraint in C++20?
IN C++20 में 'अवधारणा' बाधा क्या है?
A
template<std::integral T> — constrains T to integral types टेम्पलेट - टी को अभिन्न प्रकारों तक सीमित करता है
B
A virtual base class एक वर्चुअल बेस क्लास
C
A typedef एक टाइपडिफ़
D
A runtime check एक रनटाइम जांच
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Concepts constrain template parameters: template void f(T); only accepts integral types.
व्याख्या (हिन्दी) अवधारणाएँ टेम्प्लेट पैरामीटर्स को बाधित करती हैं: टेम्प्लेट शून्य f(T); केवल अभिन्न प्रकार स्वीकार करता है।
444
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; ए ए, बी; ए डी; अदालत
A
21 21
B
12 12
C
11 11
D
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.
445
EN + हिं
GB What is 'parameter pack expansion'?
IN 'पैरामीटर पैक विस्तार' क्या है?
A
Using ... to expand variadic template parameters विविध टेम्पलेट पैरामीटरों का विस्तार करने के लिए ... का उपयोग करना
B
Loop over template args टेम्प्लेट आर्ग पर लूप करें
C
Runtime variadic args रनटाइम विविध तर्क
D
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.
446
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
A
4.5 4.5
B
4 4
C
Compile error संकलन त्रुटि
D
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.
447
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.
व्याख्या (हिन्दी) टीएमपी गणना करने और संकलन समय पर कोड उत्पन्न करने के लिए टेम्पलेट इंस्टेंटेशन का लाभ उठाता है।
448
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.
449
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 तक विस्तारित होता है।
450
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.
436–450 of 1915