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
31
EN + हिं
GB What is the output: auto f=[]()mutable{ static int x=0; return x++; }; cout<
IN आउटपुट क्या है: auto f=[]()mutable{static int x=0; वापसी x++; }; अदालत
A
012 012
B
000 000
C
Unspecified अनिर्दिष्ट
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Order of evaluation of arguments to << is unspecified, so print order of 0,1,2 is unspecified.
व्याख्या (हिन्दी) तर्कों के मूल्यांकन का क्रम
32
EN + हिं
GB What is the output: int f(int x){return x>0?x+f(x-1):0;} cout<
IN आउटपुट क्या है: int f(int x){return x>0?x+f(x-1):0;} cout
A
10 10
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4+3+2+1=10. Output: 10.
व्याख्या (हिन्दी) 4+3+2+1=10. आउटपुट: 10.
33
EN + हिं
GB What is the output: int f(int a,int b){return a>b?f(a-b,b):a==b?0:f(a,b-a);} cout<
IN आउटपुट क्या है: int f(int a,int b){return a>b?f(a-b,b):a==b?0:f(a,b-a);} cout
A
4 4
B
8 8
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(12,8)=GCD(4,8)=GCD(4,4)=0? Wait: a==b returns 0; GCD should return a. Let me re-read: when a==b return 0. That's wrong GCD. Output: 0. Actually returns 0 when equal. Hmm. f(12,8): a>b: f(4,8); a
व्याख्या (हिन्दी) जीसीडी(12,8)=जीसीडी(4,8)=जीसीडी(4,4)=0? प्रतीक्षा करें: a==b 0 लौटाता है; जीसीडी को एक लौटाना चाहिए। मुझे दोबारा पढ़ने दीजिए: जब a==b 0 लौटाता है। यह गलत GCD है। आउटपुट: 0. वास्तव में बराबर होने पर 0 लौटाता है। हम्म। f(12,8): a>b: f(4,8); ए
34
EN + हिं
GB What is 'std::function'?
IN 'std::function' क्या है?
A
Callable storing any void() function, lambda, or functor किसी भी शून्य() फ़ंक्शन, लैम्ब्डा, या फ़ैक्टर को संग्रहीत करने योग्य कॉल करने योग्य
B
A void pointer एक शून्य सूचक
C
An event handler एक इवेंट हैंडलर
D
A C callback ए सी कॉलबैक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::function can hold any callable with signature void().
व्याख्या (हिन्दी) std::फ़ंक्शन हस्ताक्षर शून्य() के साथ किसी भी कॉल करने योग्य को पकड़ सकता है।
35
EN + हिं
GB What is the output: auto f=[](int x)->bool{return x%2==0;}; cout<
IN आउटपुट क्या है: auto f=[](int x)->bool{return x%2==0;}; अदालत
A
10 10
B
01 01
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(4)=true=1, f(3)=false=0. Output: 10.
व्याख्या (हिन्दी) f(4)=सत्य=1, f(3)=झूठा=0. आउटपुट: 10.
36
EN + हिं
GB What is the output: int f(int n,int s=0){return n?f(n/10,s+n%10):s;} cout<
IN आउटपुट क्या है: int f(int n,int s=0){return n?f(n/10,s+n%10):s;} cout
A
6 6
B
123 123
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
37
EN + हिं
GB What is 'lambda capture by move'?
IN 'लैम्ब्डा कैप्चर बाय मूव' क्या है?
A
[x=std::move(y)](){} — moves y into lambda [x=std::move(y)](){} - y को लैम्ब्डा में ले जाता है
B
Same as by reference सन्दर्भ के समान
C
C++20 only केवल सी++20
D
Captures pointer सूचक को पकड़ता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Generalized capture: [x=std::move(ptr)]() lets lambda own unique_ptr.
व्याख्या (हिन्दी) सामान्यीकृत कैप्चर: [x=std::move(ptr)]() लैम्ब्डा को अद्वितीय_ptr का स्वामी बनने देता है।
38
EN + हिं
GB What is the output: int f(int x){return x*x;} int g(int x){return x+1;} cout<
IN आउटपुट क्या है: int f(int x){return x*x;} int g(int x){return x+1;} cout
A
10 10
B
9 9
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(3)=9, g(9)=10. Output: 10.
व्याख्या (हिन्दी) f(3)=9, g(9)=10. आउटपुट: 10.
39
EN + हिं
GB What is 'std::partial_application'?
IN 'std::partial_application' क्या है?
A
Not standard; use std::bind or lambda मानक नहीं; std::bind या Lambda का उपयोग करें
B
A C++20 function एक C++20 फ़ंक्शन
C
A range algorithm एक रेंज एल्गोरिदम
D
A type trait एक प्रकार का गुण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++ has no std::partial_application; partial application achieved via std::bind or closures.
व्याख्या (हिन्दी) C++ में कोई std::partial_application नहीं है; आंशिक अनुप्रयोग std::bind या क्लोजर के माध्यम से प्राप्त किया गया।
40
EN + हिं
GB What is the output: int f(int x,int y){return x*y+x+y;} cout<
IN आउटपुट क्या है: int f(int x,int y){return x*y+x+y;} cout
A
11 11
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 6+2+3=11. Output: 11.
व्याख्या (हिन्दी) 6+2+3=11. आउटपुट: 11.
41
EN + हिं
GB What is 'std::bind_front' in C++20?
IN C++20 में 'std::bind_front' क्या है?
A
Binds leading arguments to function प्रमुख तर्कों को कार्य से जोड़ता है
B
Same as std::bind एसटीडी::बाइंड के समान
C
Deprecated पदावनत
D
Runtime binding रनटाइम बाइंडिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::bind_front(f,a) returns callable that calls f(a, ...) with additional args appended.
व्याख्या (हिन्दी) std::bind_front(f,a) कॉल करने योग्य रिटर्न देता है जो अतिरिक्त तर्कों के साथ f(a, ...) को कॉल करता है।
42
EN + हिं
GB What is the output: int f(int n){return n<2?n:f(n-1)+f(n-2);} cout<
IN आउटपुट क्या है: int f(int n){return n
A
55 55
B
34 34
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fib(10)=55. Output: 55.
व्याख्या (हिन्दी) फ़िब(10)=55. आउटपुट: 55.
43
EN + हिं
GB What is 'std::function' type erasure cost?
IN 'std::function' प्रकार मिटाने की लागत क्या है?
A
Possible heap allocation + indirect call overhead संभावित ढेर आवंटन + अप्रत्यक्ष कॉल ओवरहेड
B
No overhead कोई उपरिव्यय नहीं
C
Same as virtual वर्चुअल जैसा ही
D
Link-time cost लिंक-टाइम लागत
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::function may heap-allocate the stored callable and uses an indirect call; may not inline.
व्याख्या (हिन्दी) std::फ़ंक्शन संग्रहीत कॉल करने योग्य को ढेर-आवंटित कर सकता है और अप्रत्यक्ष कॉल का उपयोग करता है; इनलाइन नहीं हो सकता.
44
EN + हिं
GB What is the output: template int f(){return N*f();} template<> int f<0>(){return 1;} cout<();
IN आउटपुट क्या है: टेम्पलेट int f(){return N*f();} टेम्पलेट int f(){return 1;} cout
A
120 120
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5!=120. Output: 120.
व्याख्या (हिन्दी) 5!=120. आउटपुट: 120.
45
EN + हिं
GB What is 'immediately invoked function expression' (IIFE) use case?
IN 'तत्काल इनवॉक्ड फ़ंक्शन एक्सप्रेशन' (IIFE) उपयोग मामला क्या है?
A
Initialize const/constexpr with complex logic जटिल तर्क के साथ const/constexpr प्रारंभ करें
B
Recursion प्रत्यावर्तन
C
Error handling त्रुटि प्रबंधन
D
Thread safety धागे की सुरक्षा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) const auto x = [](){...complex init...}(); executes lambda immediately for const initialization.
व्याख्या (हिन्दी) const auto x = [](){...complex init...}(); कॉन्स्ट इनिशियलाइज़ेशन के लिए तुरंत लैम्ब्डा निष्पादित करता है।
31–45 of 132