OOP Using C++ — MCQ Practice

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

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

Question 16

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++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 17

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
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 18

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
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 19

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++ ("Functions" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 20

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
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Functions" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 21

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
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Functions" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 22

EN + हिं
GB What is the output: int f(int n){ return n?n+f(n-1):0; } cout<
IN आउटपुट क्या है: int f(int n){ return n?n+f(n-1):0; } कोउट
10 10
4 4
24 24
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(4)=4+f(3)=4+3+f(2)=4+3+2+f(1)=4+3+2+1+f(0)=4+3+2+1+0=10.
व्याख्या (हिन्दी) f(4)=4+f(3)=4+3+f(2)=4+3+2+f(1)=4+3+2+1+f(0)=4+3+2+1+0=10.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 23

EN + हिं
GB What is 'memoization' in the context of recursive functions?
IN पुनरावर्ती कार्यों के संदर्भ में 'संस्मरण' क्या है?
Caching results of function calls फ़ंक्शन कॉल के कैशिंग परिणाम
Memory optimization technique मेमोरी अनुकूलन तकनीक
Using static variables स्थैतिक चर का उपयोग करना
Tail call optimization टेल कॉल अनुकूलन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Memoization stores the results of expensive function calls and returns cached results when the same inputs occur again.
व्याख्या (हिन्दी) मेमोइज़ेशन महंगे फ़ंक्शन कॉल के परिणामों को संग्रहीत करता है और समान इनपुट दोबारा होने पर कैश्ड परिणाम लौटाता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 24

EN + हिं
GB What is the output: int x=10; auto f=[&](){ return ++x; }; cout<
IN आउटपुट क्या है: int x=10; ऑटो f=[&](){वापसी++x; }; अदालत
1112 1112
Unspecified अनिर्दिष्ट
1112 1112
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Order of evaluation of arguments to << is unspecified before C++17; both calls modify x but print order is unspecified.
व्याख्या (हिन्दी) तर्कों के मूल्यांकन का क्रम
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 25

EN + हिं
GB What is 'noexcept' specifier in C++?
IN C++ में 'noexcept' विनिर्देशक क्या है?
Guarantees function throws no exceptions गारंटी फ़ंक्शन कोई अपवाद नहीं देता है
Prevents exception handling अपवाद प्रबंधन को रोकता है
Makes function constexpr फ़ंक्शन कॉन्स्टेक्सपीआर बनाता है
Catches all exceptions सभी अपवादों को पकड़ता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) noexcept declares that a function will not throw exceptions; if it does, std::terminate is called.
व्याख्या (हिन्दी) noexcept घोषित करता है कि कोई फ़ंक्शन अपवाद नहीं फेंकेगा; यदि ऐसा होता है, तो std::terminet को कॉल किया जाता है।
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 26

EN + हिं
GB What is the output: int f(int x, int y=x){ return x+y; }
IN आउटपुट क्या है: int f(int x, int y=x){ return x+y; }
Works in C++17 C++17 में काम करता है
Compile error संकलन त्रुटि
Undefined behavior अपरिभाषित व्यवहार
Works if x is const यदि x स्थिरांक है तो काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default argument cannot refer to another parameter; this is a compile error.
व्याख्या (हिन्दी) डिफ़ॉल्ट तर्क किसी अन्य पैरामीटर को संदर्भित नहीं कर सकता; यह एक संकलन त्रुटि है.
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Functions" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 27

EN + हिं
GB What is the output: void f(int* p){ *p=20; } int a=10; f(&a); cout<
IN आउटपुट क्या है: void f(int* p){ *p=20; } int a=10; एफ(&ए); अदालत
10 10
20 20
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f takes pointer to int, dereferences and sets to 20, modifying a. Output: 20.
व्याख्या (हिन्दी) f पॉइंटर को int, dereferences पर ले जाता है और a को संशोधित करते हुए 20 पर सेट करता है। आउटपुट: 20.
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Functions" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 28

EN + हिं
GB What is the output: int f(int n){ return n>0?f(n/2)+1:0; } cout<
IN आउटपुट क्या है: int f(int n){ return n>0?f(n/2)+1:0; } कोउट
3 3
4 4
8 8
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(8)=f(4)+1=f(2)+2=f(1)+3=f(0)+4=0+4=4. Wait: f(8)=f(4)+1; f(4)=f(2)+1; f(2)=f(1)+1; f(1)=f(0)+1=1; f(2)=2; f(4)=3; f(8)=4. Answer: 4.
व्याख्या (हिन्दी) f(8)=f(4)+1=f(2)+2=f(1)+3=f(0)+4=0+4=4. रुको: f(8)=f(4)+1; f(4)=f(2)+1; f(2)=f(1)+1; f(1)=f(0)+1=1; एफ(2)=2; एफ(4)=3; एफ(8)=4. उत्तर: 4.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 29

EN + हिं
GB What is 'function template argument deduction'?
IN 'फ़ंक्शन टेम्प्लेट तर्क कटौती' क्या है?
Compiler deducing template args from function arguments कंपाइलर फ़ंक्शन तर्कों से टेम्प्लेट तर्क निकालता है
Manually specifying template arguments टेम्पलेट तर्कों को मैन्युअल रूप से निर्दिष्ट करना
Runtime type deduction रनटाइम प्रकार की कटौती
Only works with auto केवल ऑटो के साथ काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) When calling a function template, the compiler deduces template type parameters from the types of the provided arguments.
व्याख्या (हिन्दी) फ़ंक्शन टेम्प्लेट को कॉल करते समय, कंपाइलर प्रदान किए गए तर्कों के प्रकारों से टेम्प्लेट प्रकार के पैरामीटर निकालता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 30

EN + हिं
GB What is the output: int f(int x){ return x; } double f(double x){ return x; } cout<
IN आउटपुट क्या है: int f(int x){ return x; } डबल एफ (डबल एक्स) { रिटर्न एक्स; } कोउट
1 1
1.0 1.0
Ambiguous अस्पष्ट
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1 is int literal; exact match to f(int). Output: 1.
व्याख्या (हिन्दी) 1 पूर्णांक शाब्दिक है; f(int) से सटीक मिलान। आउटपुट: 1.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।