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
1
EN + हिं
GB What is the output: int f(int x=1,int y=2){ return x+y; } cout<
IN आउटपुट क्या है: int f(int x=1,int y=2){ return x+y; } कोउट
A
3 5 7 3 5 7
B
357 357
C
Compile error संकलन त्रुटि
D
125 125
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f()=1+2=3, f(3)=3+2=5, f(3,4)=3+4=7. Concatenated: 357.
व्याख्या (हिन्दी) f()=1+2=3, f(3)=3+2=5, f(3,4)=3+4=7. संयोजित: 357.
2
EN + हिं
GB What is the output: void f(int& x){ x=10; } int a=5; f(a); cout<
IN आउटपुट क्या है: void f(int& x){ x=10; } int a=5; एफ(ए); अदालत
A
5 5
B
10 10
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f takes a reference to int; modifying x modifies a. Output: 10.
व्याख्या (हिन्दी) f int का संदर्भ लेता है; x को संशोधित करने से a संशोधित हो जाता है। आउटपुट: 10.
3
EN + हिं
GB What is 'function overload resolution' in C++?
IN C++ में 'फ़ंक्शन ओवरलोड रिज़ॉल्यूशन' क्या है?
A
Choosing the best matching overload at compile time संकलन समय पर सर्वोत्तम मिलान अधिभार का चयन करना
B
Resolving function calls at runtime रनटाइम पर फ़ंक्शन कॉल का समाधान करना
C
Template deduction टेम्पलेट कटौती
D
Linker selecting function लिंकर चयन फ़ंक्शन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Overload resolution happens at compile time: the compiler selects the best matching function from a set of candidates based on argument types.
व्याख्या (हिन्दी) ओवरलोड रिज़ॉल्यूशन संकलन समय पर होता है: कंपाइलर तर्क प्रकारों के आधार पर उम्मीदवारों के एक सेट से सबसे अच्छे मिलान फ़ंक्शन का चयन करता है।
4
EN + हिं
GB What is a lambda closure in C++?
IN C++ में लैम्ब्डा क्लोजर क्या है?
A
A function pointer एक फ़ंक्शन सूचक
B
An anonymous function object that can capture local variables एक अनाम फ़ंक्शन ऑब्जेक्ट जो स्थानीय चर को कैप्चर कर सकता है
C
A virtual function एक आभासी कार्य
D
A member function pointer एक सदस्य फ़ंक्शन सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A lambda creates a closure object (anonymous class) that captures surrounding local variables and has operator() defined.
व्याख्या (हिन्दी) लैम्ब्डा एक क्लोजर ऑब्जेक्ट (अनाम वर्ग) बनाता है जो आसपास के स्थानीय चर को कैप्चर करता है और ऑपरेटर() को परिभाषित करता है।
5
EN + हिं
GB What is the output: int f(){ static int x=0; return ++x; } cout<
IN आउटपुट क्या है: int f(){static int x=0; वापसी++x; } कोउट
A
111 111
B
123 123
C
Unspecified अनिर्दिष्ट
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Pre-C++17, order of evaluation of arguments to << is unspecified. Each call increments x, but print order is unspecified.
व्याख्या (हिन्दी) प्री-सी++17, तर्कों के मूल्यांकन का क्रम
6
EN + हिं
GB What is 'tail call optimization'?
IN 'टेल कॉल ऑप्टिमाइज़ेशन' क्या है?
A
Optimizing the last statement अंतिम कथन का अनुकूलन
B
Reusing the caller's stack frame for a tail-recursive call टेल-रिकर्सिव कॉल के लिए कॉलर के स्टैक फ़्रेम का पुन: उपयोग करना
C
Inlining recursive functions पुनरावर्ती कार्यों को इनलाइन करना
D
Eliminating loops लूपों को हटाना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TCO allows a tail call to reuse the current stack frame, preventing stack overflow in tail-recursive functions. Not guaranteed by C++ standard but done by many compilers.
व्याख्या (हिन्दी) TCO टेल कॉल को वर्तमान स्टैक फ्रेम का पुन: उपयोग करने की अनुमति देता है, जिससे टेल-रिकर्सिव फ़ंक्शंस में स्टैक ओवरफ़्लो को रोका जा सकता है। C++ मानक द्वारा इसकी गारंटी नहीं है लेकिन कई कंपाइलरों द्वारा इसकी गारंटी दी गई है।
7
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.
8
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.
व्याख्या (हिन्दी) पास-बाय-वैल्यू तर्क की एक प्रति बनाता है; पास-बाय-रेफरेंस फ़ंक्शन को मूल तक पहुंचने और संशोधित करने की अनुमति देता है।
9
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।
10
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: जब टेम्पलेट तर्क प्रतिस्थापन विफल हो जाता है, तो संकलन त्रुटि उत्पन्न करने के बजाय टेम्पलेट को ओवरलोड सेट से हटा दिया जाता है।
11
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।
12
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.
13
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.
व्याख्या (हिन्दी) वैरिएडिक टेम्प्लेट किसी भी संख्या में टेम्प्लेट पैरामीटर को स्वीकार करने के लिए ... का उपयोग करते हैं: टेम्प्लेट।
14
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.
15
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.
व्याख्या (हिन्दी) आरवीओ/एनआरवीओ कंपाइलर को कॉपी/मूव कंस्ट्रक्टर कॉल को खत्म करते हुए सीधे कॉलर के स्थान पर रिटर्न वैल्यू बनाने की अनुमति देता है।
1–15 of 132