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 61

EN + हिं
GB What is the output: template constexpr auto makeArray(){array a{}; for(size_t i=0;i(); cout<
IN आउटपुट क्या है: template constexpr auto makeArray(){array a{}; for(size_t i=0;i
9 9
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[3]=3*3=9. Output: 9.
व्याख्या (हिन्दी) ए[3]=3*3=9. आउटपुट: 9.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 62

EN + हिं
GB What is the output: template class Optional{bool has=false; T v; public: void set(T x){has=true;v=x;} bool hasVal(){return has;} T get(){return v;}}; Optional o; cout<
IN आउटपुट क्या है: टेम्पलेट क्लास वैकल्पिक {बूल है = गलत; टी वी; सार्वजनिक: void set(T x){has=true;v=x;} bool hasVal(){return has;} T get(){return v;}}; वैकल्पिक ओ; अदालत
015 015
Compile error संकलन त्रुटि
Undefined अपरिभाषित
0 1 5 0 1 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Initial: 0. After set: 1, get=5. Output: 015.
व्याख्या (हिन्दी) आरंभिक: 0. सेट के बाद: 1, प्राप्त करें=5. आउटपुट: 015.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 63

EN + हिं
GB What is the output: template int countIf(vector& v,Pred p){int n=0;for(auto x:v) if(p(x)) n++;return n;} vectorv={1,2,3,4,5}; cout<
IN आउटपुट क्या है: टेम्पलेट int countIf(वेक्टर& v,Pred p){int n=0;for(auto x:v) if(p(x)) n++;रिटर्न n;} वेक्टरv={1,2,3,4,5}; अदालत
2 2
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2 and 4 are even. count=2. Output: 2.
व्याख्या (हिन्दी) 2 और 4 सम हैं. गिनती=2. आउटपुट: 2.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 64

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

Question 65

EN + हिं
GB What is the output: template T gcd(T a,T b){return b?gcd(b,a%b):a;} cout<
IN आउटपुट क्या है: टेम्पलेट T gcd(T a,T b){return b?gcd(b,a%b):a;} cout
12 12
6 6
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(36,48)=GCD(48,36)=GCD(36,12)=GCD(12,0)=12. Output: 12.
व्याख्या (हिन्दी) जीसीडी(36,48)=जीसीडी(48,36)=जीसीडी(36,12)=जीसीडी(12,0)=12। आउटपुट: 12.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 66

EN + हिं
GB What is the output: template vector filter(vector v,function p){vectorr;for(T x:v)if(p(x))r.push_back(x);return r;} auto r=filter({1,2,3,4,5},[](int x){return x>3;}); cout<
IN आउटपुट क्या है: टेम्पलेट वेक्टर फ़िल्टर(वेक्टर v,फ़ंक्शन p){vectorr;for(T x:v)if(p(x))r.push_back(x);return r;} auto r=filter({1,2,3,4,5},[](int x){return x>3;}); अदालत
2 2
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4 and 5. size=2. Output: 2.
व्याख्या (हिन्दी) 4 और 5. आकार=2. आउटपुट: 2.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 67

EN + हिं
GB What is the output: template T reduce(vector v,T init,function f){for(T x:v) init=f(init,x);return init;} cout<({1,2,3,4,5},0,[](int a,int b){return a+b;});
IN आउटपुट क्या है: टेम्पलेट T कम करें(वेक्टर v,T init,function f){for(T x:v) init=f(init,x);रिटर्न init;} 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) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 68

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

Question 69

EN + हिं
GB What is the output: template class Singleton{static T* inst; public: static T& get(){if(!inst) inst=new T; return *inst;} Singleton()=delete;}; template T* Singleton::inst=nullptr; struct Config{int x=42;}; cout<::get().x;
IN आउटपुट क्या है: टेम्प्लेट क्लास सिंगलटन {स्टेटिक टी * इंस्टा; सार्वजनिक: स्थिर T& get(){if(!inst) inst=new T; वापसी *इंस्ट;} सिंगलटन()=हटाएं;}; टेम्पलेट T* सिंगलटन::inst=nullptr; struct कॉन्फ़िग {int x=42;}; अदालत
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Config x=42. Output: 42.
व्याख्या (हिन्दी) कॉन्फ़िग x=42. आउटपुट: 42.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 70

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

Question 71

EN + हिं
GB What is the output: template class TypeList{}; cout<,TypeList>;
IN आउटपुट क्या है: टेम्पलेट क्लास टाइपलिस्ट{}; अदालत
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Same template with same arg: same type. is_same=1. Output: 1.
व्याख्या (हिन्दी) समान तर्क के साथ समान टेम्पलेट: समान प्रकार। समान=1 है. आउटपुट: 1.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 72

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

Question 73

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

Question 74

EN + हिं
GB What is the output: template auto zip(vectora,vectorb){vector>r;for(int i=0;i({1,2,3},{4,5,6}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ज़िप(वेक्टोरा,वेक्टरबी){वेक्टर;for(int i=0;i
25 25
14 14
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) v[1]={2,5}. first=2, second=5. Output: 25.
व्याख्या (हिन्दी) v[1]={2,5}. पहला=2, दूसरा=5. आउटपुट: 25.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 75

EN + हिं
GB What is the output: template T sq(T x){return x*x;} template<> string sq(string s){return s+s;} cout<
IN आउटपुट क्या है: टेम्पलेट T sq(T x){रिटर्न x*x;} टेम्पलेट स्ट्रिंग sq(स्ट्रिंग s){रिटर्न s+s;} कॉउट
9abab 9बाबा
Compile error संकलन त्रुटि
Undefined अपरिभाषित
9 abab 9 अबाब
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(3)=9; sq("ab")="ab"+"ab"="abab". Output: 9abab.
व्याख्या (हिन्दी) वर्ग(3)=9; sq('ab''='ab'+'ab'='abab''। आउटपुट: 9abab.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।