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
1
EN + हिं
GB What is the output: template T add(T a,T b){return a+b;} cout<
IN आउटपुट क्या है: टेम्प्लेट टी ऐड(टी ए,टी बी){रिटर्न ए+बी;} कॉउट
A
7 4 7 4
B
7 4.0 7 4.0
C
Compile error संकलन त्रुटि
D
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.
2
EN + हिं
GB What is 'template argument deduction'?
IN 'टेम्पलेट तर्क कटौती' क्या है?
A
Compiler deduces template type from function call arguments कंपाइलर फ़ंक्शन कॉल तर्कों से टेम्पलेट प्रकार का अनुमान लगाता है
B
Specifying template args explicitly टेम्पलेट तर्कों को स्पष्ट रूप से निर्दिष्ट करना
C
Runtime type deduction रनटाइम प्रकार की कटौती
D
SFINAE SFINAE
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Template argument deduction: the compiler infers T from the argument types when calling a function template.
व्याख्या (हिन्दी) टेम्प्लेट तर्क कटौती: फ़ंक्शन टेम्प्लेट को कॉल करते समय कंपाइलर तर्क प्रकारों से टी का अनुमान लगाता है।
3
EN + हिं
GB What is the output: template int f(){return N*N;} cout<();
IN आउटपुट क्या है: टेम्पलेट int f(){return N*N;} cout
A
25 25
B
5 5
C
Compile error संकलन त्रुटि
D
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.
4
EN + हिं
GB What is 'template specialization'?
IN 'टेम्पलेट विशेषज्ञता' क्या है?
A
Providing specific implementation for particular template argument विशेष टेम्पलेट तर्क के लिए विशिष्ट कार्यान्वयन प्रदान करना
B
Overloading templates टेम्प्लेट ओवरलोड हो रहे हैं
C
Runtime template selection रनटाइम टेम्पलेट चयन
D
Template inheritance टेम्पलेट विरासत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Explicit specialization: template<> void f(){} provides custom implementation for T=int.
व्याख्या (हिन्दी) स्पष्ट विशेषज्ञता: टेम्पलेट void f(){} T=int के लिए कस्टम कार्यान्वयन प्रदान करता है।
5
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.
6
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.
7
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.
8
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-यदि शर्त गलत है तो टेम्पलेट अक्षम हो जाता है।
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
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): टी=डबल, जेनेरिक: 'जी'। आउटपुट: एसजी.
10
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)।
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;}; अदालत
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.
12
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); केवल अभिन्न प्रकार स्वीकार करता है।
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; ए ए, बी; ए डी; अदालत
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.
14
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.
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
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.
1–15 of 131