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
121
EN + हिं
GB What is the output: template struct Add1{using type=T;}; template<> struct Add1{using type=long;}; template<> struct Add1{using type=long long;}; cout<::type,long><::type,char>;
IN आउटपुट क्या है: टेम्पलेट struct Add1{using type=T;}; टेम्प्लेट संरचना Add1{उपयोग प्रकार=लंबा;}; टेम्प्लेट संरचना Add1{उपयोग प्रकार=लंबा लंबा;}; अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Add1=long=1; Add1=char=1. Output: 11.
व्याख्या (हिन्दी) जोड़ें1=लंबा=1; जोड़ें1=चार=1. आउटपुट: 11.
122
EN + हिं
GB What is the output: template T arraySum(const T(&arr)[N]){T s=T{};for(auto x:arr)s+=x;return s;} int a[]={1,2,3,4,5}; cout<
IN आउटपुट क्या है: टेम्पलेट T arraySum(const T(&arr)[N]){T s=T{};for(auto x:arr)s+=x;return s;} int a[]={1,2,3,4,5}; अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) N deduced=5. Sum=15. Output: 15.
व्याख्या (हिन्दी) एन घटा=5. योग=15. आउटपुट: 15.
123
EN + हिं
GB What is the output: template auto makeShared2(auto&&...args){return make_shared(forward(args)...);} auto p=makeShared2>(5,"hi"); cout<first<second;
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकशेयर्ड2(ऑटो&&...आर्ग्स){रिटर्न मेक_शेयर्ड(फॉरवर्ड(आर्ग्स)...);} ऑटो पी=मेकशेयर्ड2(5,"हाय"); अदालत
A
5hi 5हाय
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
5 hi 5 नमस्ते
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p->first=5, p->second=hi. Output: 5hi.
व्याख्या (हिन्दी) p->पहला=5, p->दूसरा=हाय। आउटपुट: 5हाय.
124
EN + हिं
GB What is the output: template struct Traits{static constexpr bool isNum=false; static constexpr int bytes=sizeof(T);}; template<> struct Traits{static constexpr bool isNum=true; static constexpr int bytes=4;}; cout<::isNum<::bytes<::isNum;
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर ट्रैट्स {स्टेटिक कॉन्स्टेक्सपीआर बूल isNum=false; static constexpr int बाइट्स=sizeof(T);}; टेम्प्लेट संरचना लक्षण {static constexpr bool isNum=true; static constexpr int बाइट्स=4;}; अदालत
A
140 140
B
041 041
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) isNum=1, bytes=4, Traits::isNum=0. Output: 140.
व्याख्या (हिन्दी) isNum=1, बाइट्स=4, लक्षण::isNum=0. आउटपुट: 140.
125
EN + हिं
GB What is the output: template bool isInRange(T v,T lo,T hi){return v>=lo&&v<=hi;} cout<
IN आउटपुट क्या है: टेम्पलेट बूल isInRange(T v,T lo,T hi){return v>=lo&&v
A
101 101
B
010 010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 in range=1; 15 not=0; 1 in range=1. Output: 101.
व्याख्या (हिन्दी) रेंज में 5=1; 15 नहीं=0; रेंज में 1=1. आउटपुट: 101.
126
EN + हिं
GB What is the output: template vector range_(T start,T stop,T step=T(1)){vectorv;for(T i=start;i
IN आउटपुट क्या है: टेम्प्लेट वेक्टर रेंज_(टी स्टार्ट, टी स्टॉप, टी स्टेप=टी(1)){वेक्टरव;फॉर(टी आई=स्टार्ट;आई
A
37 37
B
39 39
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1,4,7: size=3, back=7. Output: 37.
व्याख्या (हिन्दी) 1,4,7: आकार=3, पिछला=7। आउटपुट: 37.
127
EN + हिं
GB What is the output: template auto applyAll(F f){if constexpr(sizeof...(Ns)>0)return f(N)+applyAll(f);else return f(N);} cout<([](int x){return x*x;});
IN आउटपुट क्या है: टेम्पलेट ऑटो अप्लाईऑल(एफ एफ){इफ कॉन्स्टेक्सप्र(साइजऑफ...(एनएस)>0)रिटर्न एफ(एन)+अप्लाईऑल(एफ);एल्स रिटर्न एफ(एन);} कॉउट
A
14 14
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
1 4 9 1 4 9
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+4+9=14. Output: 14.
व्याख्या (हिन्दी) 1+4+9=14. आउटपुट: 14.
128
EN + हिं
GB What is the output: template class TypeInfo{public:static string name(){return "unknown";}}; template<> class TypeInfo{public:static string name(){return "int";}}; template<> class TypeInfo{public:static string name(){return "double";}}; cout<::name()<<' '<::name();
IN What is the output: template class TypeInfo{public:static string name(){return "unknown";}}; template class TypeInfo{public:static string name(){return "int";}}; template class TypeInfo{public:static string name(){return "double";}}; अदालत
A
int unknown पूर्णतया अज्ञात
B
int double इंट डबल
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int=int; float=unknown. Output: int unknown.
व्याख्या (हिन्दी) int=int; तैरना=अज्ञात. आउटपुट: पूर्णांक अज्ञात.
129
EN + हिं
GB What is the output: template struct NthType{using type=typename NthType::type;}; template struct NthType<0,T,Ts...>{using type=T;}; cout<::type,double>;
IN What is the output: template struct NthType{using type=typename NthType::type;}; टेम्पलेट संरचना NthType{उपयोग प्रकार=T;}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) NthType<1,...>=double. is_same=1. Output: 1.
व्याख्या (हिन्दी) NthType=डबल. समान=1 है. आउटपुट: 1.
130
EN + हिं
GB What is the output: template auto zip_(vectora,vectorb){vector>r;for(int i=0;i({1,2,3},{10,20,30}); int s=0;for(auto[x,y]:r)s+=x*y; cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो zip_(vectora,vectorb){vectorr;for(int i=0;i
A
140 140
B
60 60
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*10+2*20+3*30=140. Output: 140.
व्याख्या (हिन्दी) 1*10+2*20+3*30=140. आउटपुट: 140.
131
EN + हिं
GB What is the output: template struct EnableType{}; template<> struct EnableType{using type=int;}; EnableType::type x=42; cout<
IN आउटपुट क्या है: टेम्पलेट संरचना EnableType{}; टेम्पलेट संरचना EnableType{using type=int;}; EnableType::type x=42; अदालत
A
42 42
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) EnableType::type=int. x=42. Output: 42.
व्याख्या (हिन्दी) EnableType::type=int. एक्स=42. आउटपुट: 42.
121–131 of 131