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 76

EN + हिं
GB What is the output: template struct Opt{bool h;T v; Opt():h(false){} Opt(T x):h(true),v(x){} T or_(T d){return h?v:d;}}; Opt a(5),b; cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर ऑप्ट{बूल एच;टी वी; Opt():h(false){} Opt(T x):h(true),v(x){} T या_(T d){return h?v:d;}}; ऑप्ट ए(5),बी; अदालत
599 599
50 50
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a has value 5; b empty. Output: 599.
व्याख्या (हिन्दी) a का मान 5 है; बी खाली. आउटपुट: 599.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 77

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

Question 78

EN + हिं
GB What is the output: template bool same(T a,U b){return is_same_v&&a==b;} cout<
IN आउटपुट क्या है: टेम्पलेट बूल समान(T a,U b){return is_same_v&&a==b;} cout
10 10
11 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) same(5,5): T=U=int, 5==5=1. same(5,5.0): T=int,U=double: is_same=false=0. Output: 10.
व्याख्या (हिन्दी) वही(5,5): टी=यू=इंट, 5==5=1। समान(5,5.0): T=int,U=डबल: is_same=false=0. आउटपुट: 10.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 79

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

Question 80

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

Question 81

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

Question 82

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

Question 83

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

Question 84

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

Question 85

EN + हिं
GB What is the output: template struct Constant{static constexpr T value=V;}; using Five=Constant; cout<
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर कॉन्स्टैंट {स्थैतिक कॉन्स्टेक्सपीआर टी वैल्यू = वी;}; पाँच=स्थिरांक का उपयोग करना; अदालत
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Five::value=5. Output: 5.
व्याख्या (हिन्दी) पाँच::मान=5. आउटपुट: 5.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 86

EN + हिं
GB What is the output: template T dot(vectora,vectorb){T s=T{};for(int i=0;i({1,2,3},{4,5,6});
IN आउटपुट क्या है: टेम्पलेट T dot(vectora,vectorb){T s=T{};for(int i=0;i
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
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Templates" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 87

EN + हिं
GB What is the output: template struct IsSame{template static bool f(){return false;} template<> static bool f(){return true;}}; cout<::f()<::f();
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर IsSame{टेम्पलेट स्टैटिक बूल f(){रिटर्न फॉल्स;} टेम्प्लेट स्टैटिक बूल f(){रिटर्न ट्रू;}}; अदालत
Compile error संकलन त्रुटि
10 10
11 11
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Explicit specialization of member template inside class body is not allowed. Compile error.
व्याख्या (हिन्दी) क्लास बॉडी के अंदर सदस्य टेम्पलेट की स्पष्ट विशेषज्ञता की अनुमति नहीं है। संकलन त्रुटि.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 88

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

Question 89

EN + हिं
GB What is the output: template void swap3(T& a,T& b,T& c){T t=a;a=b;b=c;c=t;} int x=1,y=2,z=3; swap3(x,y,z); cout<
IN आउटपुट क्या है: टेम्पलेट void swim3(T& a,T& b,T& c){T t=a;a=b;b=c;c=t;} int x=1,y=2,z=3; स्वैप3(x,y,z); अदालत
231 231
123 123
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=b=2; b=c=3; c=t=1. x=2,y=3,z=1. Output: 231.
व्याख्या (हिन्दी) ए=बी=2; बी=सी=3; सी=टी=1. x=2,y=3,z=1. आउटपुट: 231.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 90

EN + हिं
GB What is the output: template class Vec2{public:T x,y; Vec2(T a,T b):x(a),y(b){} T dot(Vec2 o){return x*o.x+y*o.y;}}; Vec2a(1,2),b(3,4); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Vec2{public:T x,y; Vec2(T a,T b):x(a),y(b){} T dot(Vec2 o){return x*o.x+y*o.y;}}; Vec2a(1,2),b(3,4); अदालत
11 11
10 10
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*3+2*4=11. Output: 11.
व्याख्या (हिन्दी) 1*3+2*4=11. आउटपुट: 11.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Templates" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।