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
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;}; अदालत
A
7 7
B
34 34
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lambda with two int parameters returns their sum. add(3,4)=7.
व्याख्या (हिन्दी) लैम्ब्डा दो पूर्णांक मापदंडों के साथ उनका योग लौटाता है। जोड़ें(3,4)=7.
137
EN + हिं
GB What is the difference between pass-by-value and pass-by-reference?
IN पास-बाय-वैल्यू और पास-बाय-रेफरेंस के बीच क्या अंतर है?
A
No difference कोई फर्क नहीं
B
Pass-by-value copies; pass-by-reference accesses original पास-बाय-वैल्यू प्रतियां; पास-दर-संदर्भ मूल तक पहुँचता है
C
Pass-by-reference copies पास-दर-संदर्भ प्रतियां
D
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.
व्याख्या (हिन्दी) पास-बाय-वैल्यू तर्क की एक प्रति बनाता है; पास-बाय-रेफरेंस फ़ंक्शन को मूल तक पहुंचने और संशोधित करने की अनुमति देता है।
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
A
120 120
B
24 24
C
60 60
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Recursive factorial: 5*4*3*2*1=120.
व्याख्या (हिन्दी) पुनरावर्ती तथ्यात्मक: 5*4*3*2*1=120।
139
EN + हिं
GB What is 'SFINAE' in C++?
IN C++ में 'SFINAE' क्या है?
A
Substitution Failure Is Not An Error प्रतिस्थापन विफलता कोई त्रुटि नहीं है
B
Standard Function Inline And Evaluate मानक फ़ंक्शन इनलाइन और मूल्यांकन करें
C
Special Function Implementation Not Allowed Elsewhere अन्यत्र विशेष कार्य कार्यान्वयन की अनुमति नहीं है
D
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: जब टेम्पलेट तर्क प्रतिस्थापन विफल हो जाता है, तो संकलन त्रुटि उत्पन्न करने के बजाय टेम्पलेट को ओवरलोड सेट से हटा दिया जाता है।
140
EN + हिं
GB What is the output: void f(int x){ cout<
IN आउटपुट क्या है: void f(int x){ cout
A
1 1
B
1.0 1.0
C
Ambiguous call अस्पष्ट कॉल
D
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।
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; } कोउट
A
5 5
C
4 4
D
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.
142
EN + हिं
GB What is a 'variadic template' in C++?
IN C++ में 'वेरिएडिक टेम्प्लेट' क्या है?
A
A template with variable number of type parameters प्रकार के पैरामीटरों की परिवर्तनीय संख्या वाला एक टेम्पलेट
B
A function with variable number of arguments तर्कों की परिवर्तनीय संख्या वाला एक फ़ंक्शन
C
A template that accepts any type एक टेम्पलेट जो किसी भी प्रकार को स्वीकार करता है
D
A C++20 concept एक C++20 अवधारणा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Variadic templates use ... to accept any number of template parameters: template.
व्याख्या (हिन्दी) वैरिएडिक टेम्प्लेट किसी भी संख्या में टेम्प्लेट पैरामीटर को स्वीकार करने के लिए ... का उपयोग करते हैं: टेम्प्लेट।
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; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
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.
144
EN + हिं
GB What is 'RVO' (Return Value Optimization)?
IN 'आरवीओ' (रिटर्न वैल्यू ऑप्टिमाइजेशन) क्या है?
A
Optimization that avoids copying return value अनुकूलन जो रिटर्न वैल्यू की प्रतिलिपि बनाने से बचाता है
B
Runtime value optimization रनटाइम मान अनुकूलन
C
Recursive value optimization पुनरावर्ती मूल्य अनुकूलन
D
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.
व्याख्या (हिन्दी) आरवीओ/एनआरवीओ कंपाइलर को कॉपी/मूव कंस्ट्रक्टर कॉल को खत्म करते हुए सीधे कॉलर के स्थान पर रिटर्न वैल्यू बनाने की अनुमति देता है।
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; अदालत
A
10 10
B
15 15
C
20 20
D
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।
146
EN + हिं
GB What is the output: auto f=[](auto x){ return x*2; }; cout<
IN आउटपुट क्या है: auto f=[](auto x){ return x*2; }; अदालत
A
105 105
B
Compile error संकलन त्रुटि
C
105.0 105.0
D
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। अदालत
147
EN + हिं
GB What happens when a function returns a reference to a local variable?
IN क्या होता है जब कोई फ़ंक्शन किसी स्थानीय चर का संदर्भ लौटाता है?
A
Compile error always हमेशा त्रुटि संकलित करें
B
Undefined behavior (dangling reference) अपरिभाषित व्यवहार (लटकता संदर्भ)
C
Reference extends variable lifetime संदर्भ परिवर्तनीय जीवनकाल का विस्तार करता है
D
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.
व्याख्या (हिन्दी) स्थानीय चर के संदर्भ को वापस करने से एक लटकता हुआ संदर्भ (अपरिभाषित व्यवहार) बनता है क्योंकि वापसी पर स्थानीय नष्ट हो जाता है।
148
EN + हिं
GB What is the output: int f(){ return 1; } int g(){ return 2; } cout<
IN आउटपुट क्या है: int f(){ return 1; } int g(){वापसी 2; } कोउट
A
3 3
B
12 12
C
Unspecified order अनिर्दिष्ट आदेश
D
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() के मूल्यांकन का क्रम अनिर्दिष्ट है लेकिन परिणाम नियतात्मक है।
149
EN + हिं
GB What is 'perfect forwarding' in C++?
IN C++ में 'परफेक्ट फ़ॉरवर्डिंग' क्या है?
A
Passing arguments preserving their value category (lvalue/rvalue) उनकी मूल्य श्रेणी (lvalue/rvalue) को संरक्षित करते हुए तर्क पारित करना
B
Inlining function calls इनलाइनिंग फ़ंक्शन कॉल
C
Forwarding return values वापसी मान अग्रेषित करना
D
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 प्रकृति को संरक्षित करता है।
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; एफ(ए); अदालत
A
100 100
B
5 5
C
Undefined अपरिभाषित
D
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.
136–150 of 1915