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
451
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) प्रकारों के बारे में संकलन-समय की जानकारी प्रदान करते हैं।
452
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.
453
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.
454
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'। सामान्य नाम टाइप करें: 'अज्ञात'। आउटपुट: अज्ञात.
455
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.
456
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.
व्याख्या (हिन्दी) क्लास टेम्प्लेट कक्षाओं के एक परिवार को परिभाषित करते हैं; फ़ंक्शन टेम्प्लेट फ़ंक्शंस के एक परिवार को परिभाषित करते हैं। दोनों विशेषज्ञता का समर्थन करते हैं।
457
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.
458
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 को टेम्पलेट तर्क कैसे निकालना चाहिए: जोड़ी (टी, यू) -> जोड़ी;
459
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.
460
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।
461
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::वेक्टर; उस अनुवाद इकाई में तात्कालिकता को बल देता है, जो संकलन समय को कम करने के लिए उपयोगी है।
462
EN + हिं
GB What is the output: cout<<(1<<3)+(1<<2)+(1<<0);
IN आउटपुट क्या है: cout
A
13 13
B
8 8
C
14 14
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 8+4+1=13.
व्याख्या (हिन्दी) 8+4+1=13.
463
EN + हिं
GB What is 'alignment' in C++?
IN C++ में 'संरेखण' क्या है?
A
Memory address constraint for a type एक प्रकार के लिए मेमोरी एड्रेस बाधा
B
Cache line size कैश लाइन का आकार
C
Struct packing संरचना पैकिंग
D
Padding removal पैडिंग हटाना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Alignment: CPU requires objects at addresses divisible by their alignment (e.g., int at 4-byte boundary).
व्याख्या (हिन्दी) संरेखण: सीपीयू को उनके संरेखण द्वारा विभाज्य पते पर वस्तुओं की आवश्यकता होती है (उदाहरण के लिए, 4-बाइट सीमा पर int)।
464
EN + हिं
GB What is the output: int x=5; cout<<(x>0)+(x>3)+(x>4)+(x>5);
IN आउटपुट क्या है: int x=5; cout3)+(x>4)+(x>5);
A
3 3
B
4 4
C
2 2
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+1+1+0=3. Output: 3.
व्याख्या (हिन्दी) 1+1+1+0=3. आउटपुट: 3.
465
EN + हिं
GB What does 'explicit' keyword prevent?
IN 'स्पष्ट' कीवर्ड क्या रोकता है?
A
Implicit single-argument constructor conversion अंतर्निहित एकल-तर्क कंस्ट्रक्टर रूपांतरण
B
Copy construction निर्माण की प्रतिलिपि बनाएँ
C
Virtual dispatch आभासी प्रेषण
D
Template instantiation टेम्पलेट इन्स्टेन्शियशन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) explicit prevents compiler using constructor for implicit type conversion.
व्याख्या (हिन्दी) स्पष्ट अंतर्निहित प्रकार के रूपांतरण के लिए कंस्ट्रक्टर का उपयोग करने वाले कंपाइलर को रोकता है।
451–465 of 1915