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 46

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

Question 47

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

Question 48

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

Question 49

EN + हिं
GB What is the output: template bool between(T v,T lo,T hi){return v>=lo&&v<=hi;} cout<
IN आउटपुट क्या है: टेम्पलेट बूल बीच(टी वी,टी लो,टी हाय){रिटर्न वी>=लो&&वी
10 10
11 11
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 in [1,10]=1; 15 not=0. Output: 10.
व्याख्या (हिन्दी) 5 में [1,10]=1; 15 नहीं=0. आउटपुट: 10.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 50

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

Question 51

EN + हिं
GB What is the output: template struct TypeOf{static string name(){return "unknown";}}; template<> struct TypeOf{static string name(){return "int";}}; cout<::name()<::name();
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर टाइपऑफ़ {स्टैटिक स्ट्रिंग नेम() {रिटर्न "अज्ञात";}}; टेम्प्लेट संरचना प्रकारOf{स्थैतिक स्ट्रिंग नाम(){वापसी "int";}}; अदालत
intunknown अनजान
Compile error संकलन त्रुटि
Undefined अपरिभाषित
int double इंट डबल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TypeOf=int; TypeOf=unknown. Output: intunknown.
व्याख्या (हिन्दी) टाइपऑफ=इंट; टाइपऑफ=अज्ञात. आउटपुट: अज्ञात.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Templates" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 52

EN + हिं
GB What is the output: template struct Array{T d[N]; int size(){return N;} T& at(int i){return d[i];}}; Array a; a.at(0)=1;a.at(1)=2;a.at(2)=3; cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर ऐरे {टी डी [एन]; int size(){return N;} T& at(int i){return d[i];}}; सरणी ए; a.at(0)=1;a.at(1)=2;a.at(2)=3; अदालत
32 32
31 31
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=3, at(1)=2. Output: 32.
व्याख्या (हिन्दी) आकार=3, पर(1)=2. आउटपुट: 32.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 53

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

Question 54

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

Question 55

EN + हिं
GB What is the output: template T fromString(const string& s); template<> int fromString(const string& s){return stoi(s);} cout<("42");
IN आउटपुट क्या है: टेम्पलेट T fromString(const string& s); टेम्पलेट int fromString(const string& s){return Stoi(s);} cout
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) fromString("42")=42. Output: 42.
व्याख्या (हिन्दी) fromString("42")=42. आउटपुट: 42.
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 56

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

Question 57

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

Question 58

EN + हिं
GB What is the output: template void f(T){cout<<'T';} template<> void f(int){cout<<'I';} f(1); f(1.0); f('a');
IN आउटपुट क्या है: टेम्पलेट शून्य f(T){cout
ITT आईटीटी
TTT टीटीटी
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(1): T=int: 'I'. f(1.0): T=double: 'T'. f('a'): T=char: 'T'. Output: ITT.
व्याख्या (हिन्दी) एफ(1): टी=इंट: 'आई'। एफ(1.0): टी=डबल: 'टी'। एफ('ए'): टी=चार: 'टी'। आउटपुट: आईटीटी।
🎯 Exam Perspective
OOP Using C++ ("Templates" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 59

EN + हिं
GB What is the output: template auto makeVec(T a,T b,T c)->vector{return {a,b,c};} auto v=makeVec(1,2,3); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकवेक(टी ए,टी बी,टी सी)->वेक्टर{रिटर्न {ए,बी,सी};} ऑटो वी=मेकवेक(1,2,3); अदालत
4 4
6 6
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) v[0]=1,v[2]=3. 1+3=4. Output: 4.
व्याख्या (हिन्दी) v[0]=1,v[2]=3. 1+3=4. आउटपुट: 4.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Templates" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 60

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