OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye.

📚 1915 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
1915 questions

Question 136

EN + हिं
GB What is the output: auto add=[](int a,int b){return a+b;}; cout<
IN आउटपुट क्या है: auto add=[](int a,int b){return a+b;}; अदालत
7 7
34 34
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lambda with two int parameters returns their sum. add(3,4)=7.
व्याख्या (हिन्दी) लैम्ब्डा दो पूर्णांक मापदंडों के साथ उनका योग लौटाता है। जोड़ें(3,4)=7.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 137

EN + हिं
GB What is the difference between pass-by-value and pass-by-reference?
IN पास-बाय-वैल्यू और पास-बाय-रेफरेंस के बीच क्या अंतर है?
No difference कोई फर्क नहीं
Pass-by-value copies; pass-by-reference accesses original पास-बाय-वैल्यू प्रतियां; पास-दर-संदर्भ मूल तक पहुँचता है
Pass-by-reference copies पास-दर-संदर्भ प्रतियां
Pass-by-value is faster always पास-बाय-वैल्यू हमेशा तेज़ होता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Pass-by-value creates a copy of the argument; pass-by-reference allows the function to access and modify the original.
व्याख्या (हिन्दी) पास-बाय-वैल्यू तर्क की एक प्रति बनाता है; पास-बाय-रेफरेंस फ़ंक्शन को मूल तक पहुंचने और संशोधित करने की अनुमति देता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 138

EN + हिं
GB What is the output: int f(int n){ return n<=1?1:n*f(n-1); } cout<
IN आउटपुट क्या है: int f(int n){ return n
120 120
24 24
60 60
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Recursive factorial: 5*4*3*2*1=120.
व्याख्या (हिन्दी) पुनरावर्ती तथ्यात्मक: 5*4*3*2*1=120।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 139

EN + हिं
GB What is 'SFINAE' in C++?
IN C++ में 'SFINAE' क्या है?
Substitution Failure Is Not An Error प्रतिस्थापन विफलता कोई त्रुटि नहीं है
Standard Function Inline And Evaluate मानक फ़ंक्शन इनलाइन और मूल्यांकन करें
Special Function Implementation Not Allowed Elsewhere अन्यत्र विशेष कार्य कार्यान्वयन की अनुमति नहीं है
Static Function Initialization And Execution स्थैतिक फ़ंक्शन आरंभीकरण और निष्पादन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) SFINAE: when template argument substitution fails, the template is removed from overload set rather than causing a compile error.
व्याख्या (हिन्दी) SFINAE: जब टेम्पलेट तर्क प्रतिस्थापन विफल हो जाता है, तो संकलन त्रुटि उत्पन्न करने के बजाय टेम्पलेट को ओवरलोड सेट से हटा दिया जाता है।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 140

EN + हिं
GB What is the output: void f(int x){ cout<
IN आउटपुट क्या है: void f(int x){ cout
1 1
1.0 1.0
Ambiguous call अस्पष्ट कॉल
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) float argument: float->double is better conversion than float->int. So f(double) is called, prints 1.
व्याख्या (हिन्दी) फ्लोट तर्क: फ्लोट->डबल फ्लोट->इंट की तुलना में बेहतर रूपांतरण है। तो f(double) कहा जाता है, प्रिंट 1।
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 141

EN + हिं
GB What is the output: int f(int n){ if(n==0) return 0; return f(n-1)+1; } cout<
IN आउटपुट क्या है: int f(int n){ if(n==0) return 0; वापसी f(n-1)+1; } कोउट
5 5
4 4
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Each call adds 1 to result of f(n-1). f(5)=f(4)+1=...=f(0)+5=0+5=5.
व्याख्या (हिन्दी) प्रत्येक कॉल f(n-1) के परिणाम में 1 जोड़ती है। f(5)=f(4)+1=...=f(0)+5=0+5=5.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 142

EN + हिं
GB What is a 'variadic template' in C++?
IN C++ में 'वेरिएडिक टेम्प्लेट' क्या है?
A template with variable number of type parameters प्रकार के पैरामीटरों की परिवर्तनीय संख्या वाला एक टेम्पलेट
A function with variable number of arguments तर्कों की परिवर्तनीय संख्या वाला एक फ़ंक्शन
A template that accepts any type एक टेम्पलेट जो किसी भी प्रकार को स्वीकार करता है
A C++20 concept एक C++20 अवधारणा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Variadic templates use ... to accept any number of template parameters: template.
व्याख्या (हिन्दी) वैरिएडिक टेम्प्लेट किसी भी संख्या में टेम्प्लेट पैरामीटर को स्वीकार करने के लिए ... का उपयोग करते हैं: टेम्प्लेट।
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 143

EN + हिं
GB What is the output: int f(int x){ return x*2; } int(*fp)(int)=f; cout<
IN आउटपुट क्या है: int f(int x){ return x*2; } int(*fp)(int)=f; अदालत
10 10
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) fp is a function pointer to f. fp(5)=f(5)=5*2=10.
व्याख्या (हिन्दी) एफपी, एफ के लिए एक फ़ंक्शन पॉइंटर है। एफपी(5)=एफ(5)=5*2=10.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 144

EN + हिं
GB What is 'RVO' (Return Value Optimization)?
IN 'आरवीओ' (रिटर्न वैल्यू ऑप्टिमाइजेशन) क्या है?
Optimization that avoids copying return value अनुकूलन जो रिटर्न वैल्यू की प्रतिलिपि बनाने से बचाता है
Runtime value optimization रनटाइम मान अनुकूलन
Recursive value optimization पुनरावर्ती मूल्य अनुकूलन
Reference value output संदर्भ मान आउटपुट
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) RVO/NRVO allows compiler to construct the return value directly in the caller's space, eliminating copy/move constructor calls.
व्याख्या (हिन्दी) आरवीओ/एनआरवीओ कंपाइलर को कॉपी/मूव कंस्ट्रक्टर कॉल को खत्म करते हुए सीधे कॉलर के स्थान पर रिटर्न वैल्यू बनाने की अनुमति देता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 145

EN + हिं
GB What is the output: int f(int& a, int b){ a=10; return a+b; } int x=5; cout<
IN आउटपुट क्या है: int f(int& a, int b){ a=10; वापसी a+b; } int x=5; अदालत
10 10
15 15
20 20
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b is passed by value (=5 at call time). Inside f: a=10, return 10+5=15.
व्याख्या (हिन्दी) b को मान (=कॉल समय पर 5) से पारित किया जाता है। f के अंदर: a=10, वापसी 10+5=15।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 146

EN + हिं
GB What is the output: auto f=[](auto x){ return x*2; }; cout<
IN आउटपुट क्या है: auto f=[](auto x){ return x*2; }; अदालत
105 105
Compile error संकलन त्रुटि
105.0 105.0
Generic lambda requires C++20 जेनेरिक लैम्ब्डा को C++20 की आवश्यकता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Generic lambda (C++14+): f(5)=10, f(2.5)=5.0. cout<<10<<5 outputs '105'.
व्याख्या (हिन्दी) जेनेरिक लैम्ब्डा (C++14+): f(5)=10, f(2.5)=5.0। अदालत
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 147

EN + हिं
GB What happens when a function returns a reference to a local variable?
IN क्या होता है जब कोई फ़ंक्शन किसी स्थानीय चर का संदर्भ लौटाता है?
Compile error always हमेशा त्रुटि संकलित करें
Undefined behavior (dangling reference) अपरिभाषित व्यवहार (लटकता संदर्भ)
Reference extends variable lifetime संदर्भ परिवर्तनीय जीवनकाल का विस्तार करता है
Safe if variable is static यदि परिवर्तनशील स्थिर है तो सुरक्षित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Returning a reference to a local variable creates a dangling reference (undefined behavior) because the local is destroyed on return.
व्याख्या (हिन्दी) स्थानीय चर के संदर्भ को वापस करने से एक लटकता हुआ संदर्भ (अपरिभाषित व्यवहार) बनता है क्योंकि वापसी पर स्थानीय नष्ट हो जाता है।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 148

EN + हिं
GB What is the output: int f(){ return 1; } int g(){ return 2; } cout<
IN आउटपुट क्या है: int f(){ return 1; } int g(){वापसी 2; } कोउट
3 3
12 12
Unspecified order अनिर्दिष्ट आदेश
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f()+g() = 1+2 = 3. The order of evaluation of f() and g() is unspecified but result is deterministic.
व्याख्या (हिन्दी) f()+g() = 1+2 = 3. f() और g() के मूल्यांकन का क्रम अनिर्दिष्ट है लेकिन परिणाम नियतात्मक है।
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 149

EN + हिं
GB What is 'perfect forwarding' in C++?
IN C++ में 'परफेक्ट फ़ॉरवर्डिंग' क्या है?
Passing arguments preserving their value category (lvalue/rvalue) उनकी मूल्य श्रेणी (lvalue/rvalue) को संरक्षित करते हुए तर्क पारित करना
Inlining function calls इनलाइनिंग फ़ंक्शन कॉल
Forwarding return values वापसी मान अग्रेषित करना
Template specialization forwarding टेम्पलेट विशेषज्ञता अग्रेषण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::forward(arg) preserves the lvalue/rvalue nature of the argument for perfect forwarding in template functions.
व्याख्या (हिन्दी) std::forward(arg) टेम्प्लेट फ़ंक्शंस में सही अग्रेषण के लिए तर्क की lvalue/rvalue प्रकृति को संरक्षित करता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 150

EN + हिं
GB What is the output: void f(int x){ x=100; } int a=5; f(a); cout<
IN आउटपुट क्या है: void f(int x){ x=100; } int a=5; एफ(ए); अदालत
100 100
5 5
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x is passed by value; modifying x inside f doesn't affect a. Output: 5.
व्याख्या (हिन्दी) x मान द्वारा पारित किया गया है; x को f के अंदर संशोधित करने से a प्रभावित नहीं होता है। आउटपुट: 5.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।