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

Question 106

EN + हिं
GB What is the output: template T dotProduct(vectora,vectorb){return inner_product(a.begin(),a.end(),b.begin(),T{});} cout<({1,2,3},{4,5,6});
IN आउटपुट क्या है: टेम्पलेट T dotProduct(vectora,vectorb){return inside_product(a.begin(),a.end(),b.begin(),T{});} cout
32 32
15 15
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*4+2*5+3*6=32. Output: 32.
व्याख्या (हिन्दी) 1*4+2*5+3*6=32. आउटपुट: 32.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 107

EN + हिं
GB What is the output: template class Pair2{T first,second; public:Pair2(T a,T b):first(a),second(b){} T min_()const{return firstsecond?first:second;}}; Pair2p(3,7); cout<
IN आउटपुट क्या है: टेम्पलेट वर्ग Pair2{T प्रथम, द्वितीय; सार्वजनिक:जोड़ी2(टी ए,टी बी):पहला(ए),दूसरा(बी){} टी मिनट_() स्थिरांक{पहले लौटाएंदूसरा?पहला:दूसरा;}}; जोड़ी2पी(3,7); अदालत
37 37
73 73
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min=3,max=7. Output: 37.
व्याख्या (हिन्दी) न्यूनतम=3,अधिकतम=7. आउटपुट: 37.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 108

EN + हिं
GB What is the output: template struct TypeSize{static constexpr int v=sizeof(T);}; cout<::v<::v<::v;
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर टाइपसाइज़{static constexpr int v=sizeof(T);}; अदालत
481 481
841 841
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int=4, double=8, char=1. Output: 481.
व्याख्या (हिन्दी) int=4, डबल=8, char=1. आउटपुट: 481.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 109

EN + हिं
GB What is the output: template T zipAdd(vectora,vectorb){T s=T{};for(int i=0;i({1,2,3},{10,20,30});
IN आउटपुट क्या है: टेम्पलेट T zipAdd(vectora,vectorb){T s=T{};for(int i=0;i
140 140
60 60
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*10+2*20+3*30=10+40+90=140. Output: 140.
व्याख्या (हिन्दी) 1*10+2*20+3*30=10+40+90=140. आउटपुट: 140.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 110

EN + हिं
GB What is the output: template T myMax2(T a,T b,Comp comp){return comp(a,b)?b:a;} cout<
IN आउटपुट क्या है: टेम्पलेट T myMax2(T a,T b,Comp COMP){रिटर्न COMP(a,b)?b:a;} cout
7 7
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) comp(3,7)=3<7=true: return b=7. Output: 7.
व्याख्या (हिन्दी) COMP(3,7)=3
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 111

EN + हिं
GB What is the output: template struct Lit{static constexpr auto value=V;}; cout<::value<::value;
IN आउटपुट क्या है: टेम्पलेट struct Lit{static constexpr auto value=V;}; अदालत
423.14 423.14
Compile error संकलन त्रुटि
Undefined अपरिभाषित
42 3 42 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42 and 3.14. Output: 423.14.
व्याख्या (हिन्दी) 42 और 3.14. आउटपुट: 423.14.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 112

EN + हिं
GB What is the output: template T reduce2(vectorv,T init,functionf){return accumulate(v.begin(),v.end(),init,f);} cout<({1,2,3,4,5},0,[](int a,int b){return a+b;});
IN आउटपुट क्या है: टेम्पलेट T कम2(वेक्टरv,T init,functionf){रिटर्न एक्युमेटेड(v.begin(),v.end(),init,f);} cout
15 15
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 113

EN + हिं
GB What is the output: template class Stack2{vectors; public:void push(T x){s.push_back(x);} T pop(){T x=s.back();s.pop_back();return x;} T top()const{return s.back();} bool empty()const{return s.empty();}}; Stack2st; st.push(1);st.push(2);st.push(3); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Stack2{वेक्टर; सार्वजनिक:शून्य पुश(टी x){s.push_back(x);} T पॉप(){T x=s.back();s.pop_back();रिटर्न x;} T टॉप()const{रिटर्न s.बैक();} बूल खाली()const{रिटर्न s.empty();}}; स्टैक2st; st.push(1);st.push(2);st.push(3); अदालत
32 32
23 23
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) pop=3; top=2. Output: 32.
व्याख्या (हिन्दी) पॉप=3; शीर्ष=2. आउटपुट: 32.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 114

EN + हिं
GB What is the output: template bool isPalin(const vector&v){return equal(v.begin(),v.begin()+v.size()/2,v.rbegin());} cout<{1,2,3,2,1})<{1,2,3});
IN आउटपुट क्या है: टेम्प्लेट बूल isPalin(const वेक्टर&v){रिटर्न इक्वल(v.begin(),v.begin()+v.size()/2,v.rbegin());} cout
10 10
11 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First=palindrome=1; second=not=0. Output: 10.
व्याख्या (हिन्दी) प्रथम=पैलिंड्रोम=1; दूसरा=नहीं=0. आउटपुट: 10.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 115

EN + हिं
GB What is the output: template struct Pow2{static const int v=2*Pow2::v;}; template<> struct Pow2<0>{static const int v=1;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट struct Pow2{static const int v=2*Pow2::v;}; टेम्पलेट संरचना Pow2{static const int v=1;}; अदालत
1024 1024
512 512
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2^10=1024. Output: 1024.
व्याख्या (हिन्दी) 2^10=1024. आउटपुट: 1024.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 116

EN + हिं
GB What is the output: template T accumulate2(T* begin,T* end,T init){while(begin!=end)init+=*begin++;return init;} int a[]={1,2,3,4,5}; cout<
IN What is the output: template T accumulate2(T* begin,T* end,T init){while(begin!=end)init+=*begin++;return init;} int a[]={1,2,3,4,5}; अदालत
15 15
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 117

EN + हिं
GB What is the output: template class Maybe{optionalv; public:Maybe():v{}{} Maybe(T x):v(x){} template auto bind(F f)->Maybe{if(!v)return {};return {f(*v)};} T orElse(T d)const{return v.value_or(d);}}; Maybem(5); auto r=m.bind([](int x){return x*2;}).bind([](int x){return x+1;}); cout<
IN What is the output: template class Maybe{optionalv; सार्वजनिक:हो सकता है():v{} शायद(T x):v(x){} टेम्पलेट ऑटो बाइंड(F f)->शायद{if(!v)रिटर्न {};रिटर्न {f(*v)};} T या अन्यथा(T d)const{रिटर्न v.value_or(d);}}; मेबेम(5); auto r=m.bind([](int x){return x*2;}).bind([](int x){return x+1;}); अदालत
11 11
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+1=11. Output: 11.
व्याख्या (हिन्दी) 5*2=10; 10+1=11. आउटपुट: 11.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 118

EN + हिं
GB What is the output: template T fromStr(const string& s); template<> int fromStr(const string& s){return stoi(s);} template<> double fromStr(const string& s){return stod(s);} cout<("42")+fromStr("3.5");
IN आउटपुट क्या है: टेम्पलेट T fromStr(const string& s); टेम्पलेट int fromStr(const string& s){return Stoi(s);} टेम्पलेट डबल fromStr(const string& s){return Stod(s);} cout
45.5 45.5
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42+3.5=45.5. Output: 45.5.
व्याख्या (हिन्दी) 42+3.5=45.5. आउटपुट: 45.5.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 119

EN + हिं
GB What is the output: template auto groupBy(vectorv,functionf)->map>{map>m;for(T x:v)m[f(x)].push_back(x);return m;} auto g=groupBy({1,2,3,4,5,6},[](int x){return x%3;}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ग्रुपबी(वेक्टरवी,फंक्शनएफ)->मैप{मैपम;फॉर(टी एक्स:वी)एम[एफ(एक्स)].पुश_बैक(एक्स);रिटर्न एम;} ऑटो जी=ग्रुपबी({1,2,3,4,5,6},[](इंट एक्स){रिटर्न x%3;}); अदालत
222 222
321 321
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0:{3,6}=2; 1:{1,4}=2; 2:{2,5}=2. Output: 222.
व्याख्या (हिन्दी) 0:{3,6}=2; 1:{1,4}=2; 2:{2,5}=2. आउटपुट: 222.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 120

EN + हिं
GB What is the output: template struct Reverse{using type=T;}; template struct Reverse>{using rest=typename Reverse>::type; using type=decltype(tuple_cat(declval(),declval>()));}; cout<>::type,tuple>;
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर रिवर्स {उपयोग प्रकार = टी;}; टेम्प्लेट संरचना रिवर्स {बाकी का उपयोग करके = टाइपनाम रिवर्स::टाइप; type=decltype(tuple_cat(declval(),declval()));} का उपयोग करना; अदालत
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Reversed tuple=tuple. is_same=1. Output: 1.
व्याख्या (हिन्दी) उलटा टुपल = टुपल। समान=1 है. आउटपुट: 1.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।