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
46
EN + हिं
GB What is the output: int f(int a,int b=2,int c=3){return a*b*c;} cout<
IN आउटपुट क्या है: int f(int a,int b=2,int c=3){return a*b*c;} cout
A
61220 61220
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
6 12 20 6 12 20
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(1)=1*2*3=6; f(1,4)=1*4*3=12; f(1,4,5)=1*4*5=20. Output: 61220.
व्याख्या (हिन्दी) f(1)=1*2*3=6; f(1,4)=1*4*3=12; f(1,4,5)=1*4*5=20. आउटपुट: 61220.
47
EN + हिं
GB What is 'std::invoke_result_t'?
IN 'std::invoke_result_t' क्या है?
A
Type of result of invoking callable with args आर्गों के साथ कॉल करने योग्य को लागू करने के परिणाम का प्रकार
B
Same as decltype डिक्ल्टाइप के समान
C
Runtime type रनटाइम प्रकार
D
A concept संप्रत्यय
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::invoke_result_t gives return type of F(Args...) at compile time.
व्याख्या (हिन्दी) std::invoke_result_t संकलन समय पर F(Args...) का रिटर्न प्रकार देता है।
48
EN + हिं
GB What is the output: int f(int n){int r=1; while(n>1) r*=n (1, 6, 75, 5, 4, 'What is 'noexcept' function and move semantics?
IN आउटपुट क्या है: int f(int n){int r=1; जबकि(n>1) r*=n (1, 6, 75, 5, 4, 'What is 'noexcept' function and move semantics?
A
noexcept move constructor enables std::vector to move instead of copy on reallocation noexcept मूव कंस्ट्रक्टर std::vector को पुन:आवंटन पर कॉपी करने के बजाय स्थानांतरित करने में सक्षम बनाता है
B
No relation कोई संबंध नहीं
C
Makes moves faster तेजी से कदम बढ़ाता है
D
C++17 only केवल सी++17
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::vector uses move constructor only if it is noexcept; otherwise falls back to copy for exception safety.
व्याख्या (हिन्दी) std::vector मूव कंस्ट्रक्टर का उपयोग केवल तभी करता है जब यह कोई अपवाद न हो; अन्यथा अपवाद सुरक्षा के लिए प्रतिलिपि पर वापस आ जाता है।
49
EN + हिं
GB What is 'noexcept' function and move semantics?
IN 'नोएक्सेप्ट' फ़ंक्शन और मूव सिमेंटिक्स क्या है?
A
noexcept move constructor enables std::vector to move instead of copy on reallocation noexcept मूव कंस्ट्रक्टर std::vector को पुन:आवंटन पर कॉपी करने के बजाय स्थानांतरित करने में सक्षम बनाता है
B
No relation कोई संबंध नहीं
C
Makes moves faster तेजी से कदम बढ़ाता है
D
C++17 only केवल सी++17
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::vector uses move constructor only if it is noexcept; otherwise falls back to copy for exception safety.
व्याख्या (हिन्दी) std::vector मूव कंस्ट्रक्टर का उपयोग केवल तभी करता है जब यह कोई अपवाद न हो; अन्यथा अपवाद सुरक्षा के लिए प्रतिलिपि पर वापस आ जाता है।
50
EN + हिं
GB What is the output: auto f=[](auto x,auto y){return x
IN आउटपुट क्या है: ऑटो f=[](ऑटो x,ऑटो y){रिटर्न x
A
32.0 32.0
B
Compile error संकलन त्रुटि
C
35 35
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(3,5)=3, f(4.0,2.0)=2.0. Output: 32.
व्याख्या (हिन्दी) f(3,5)=3, f(4.0,2.0)=2.0. आउटपुट: 32.
51
EN + हिं
GB What is 'overloading vs overriding'?
IN 'ओवरलोडिंग बनाम ओवरराइडिंग' क्या है?
A
Overloading: same name diff params; overriding: replaces virtual ओवरलोडिंग: समान नाम भिन्न पैरामीटर; ओवरराइडिंग: वर्चुअल को प्रतिस्थापित करता है
B
Same thing एक ही बात
C
Overriding is compile-time ओवरराइडिंग संकलन-समय है
D
Overloading is runtime ओवरलोडिंग रनटाइम है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Overloading is compile-time selection by signature; overriding is runtime dispatch via vtable.
व्याख्या (हिन्दी) ओवरलोडिंग हस्ताक्षर द्वारा संकलन-समय चयन है; ओवरराइडिंग vtable के माध्यम से रनटाइम प्रेषण है।
52
EN + हिं
GB What is the output: int f(int x){return x?x^f(x-1):0;} cout<
IN आउटपुट क्या है: int f(int x){return x?x^f(x-1):0;} cout
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(5)=5^f(4)=5^(4^f(3))=5^4^3^2^1^0=1. Output: 1.
व्याख्या (हिन्दी) f(5)=5^f(4)=5^(4^f(3))=5^4^3^2^1^0=1. आउटपुट: 1.
53
EN + हिं
GB What is the output: int r=0; auto f=[&r](auto self,int n)->void{if(n>0){r+=n;self(self,n-1);}}; f(f,5); cout<
IN आउटपुट क्या है: int r=0; auto f=[&r](auto self,int n)->void{if(n>0){r+=n;self(self,n-1);}}; एफ(एफ,5); अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5+4+3+2+1=15. Output: 15.
व्याख्या (हिन्दी) 5+4+3+2+1=15. आउटपुट: 15.
54
EN + हिं
GB What is 'std::transform_reduce'?
IN 'std::transform_reduce' क्या है?
A
Map then reduce: apply transform then reduction मानचित्र फिर कम करें: परिवर्तन लागू करें फिर कमी करें
B
Same as inner_product आंतरिक_उत्पाद के समान
C
Parallel sort समानांतर प्रकार
D
A filter+map एक फ़िल्टर+मानचित्र
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) transform_reduce applies a unary op to elements then reduces; parallel version of inner_product.
व्याख्या (हिन्दी) ट्रांसफ़ॉर्म_रिड्यूस तत्वों पर एक यूनरी ऑप लागू करता है और फिर कम कर देता है; इनर_प्रोडक्ट का समानांतर संस्करण।
55
EN + हिं
GB What is the output: int f(int x){return x;} auto& g=f; cout<
IN आउटपुट क्या है: int f(int x){return x;} auto& g=f; अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Function references work like function pointers. g(5)=f(5)=5. Output: 5.
व्याख्या (हिन्दी) फ़ंक्शन संदर्भ फ़ंक्शन पॉइंटर्स की तरह काम करते हैं। g(5)=f(5)=5. आउटपुट: 5.
56
EN + हिं
GB What is 'trailing requires clause' in C++20?
IN C++20 में 'ट्रेलिंग रिक्वायर्ड क्लॉज' क्या है?
A
auto f(T x) requires Concept<T> — constrains template ऑटो f(T x) के लिए संकल्पना - बाधा टेम्पलेट की आवश्यकता होती है
B
Same as enable_if Enable_if के समान
C
Runtime check रनटाइम जांच
D
A return type एक वापसी प्रकार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Trailing requires: template void f(T) requires std::integral{} — cleaner than enable_if.
व्याख्या (हिन्दी) ट्रेलिंग के लिए आवश्यक है: टेम्पलेट शून्य f(T) के लिए std::integral{} की आवश्यकता है - Enable_if की तुलना में अधिक साफ़।
57
EN + हिं
GB What is the output: int f(int x,int y){return x==0?y:f(y%x,x);} cout<
IN आउटपुट क्या है: int f(int x,int y){return x==0?y:f(y%x,x);} cout
A
14 14
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(56,98): f(98%56,56)=f(42,56)=f(56%42,42)=f(14,42)=f(42%14,14)=f(0,14)=14. Output: 14.
व्याख्या (हिन्दी) जीसीडी(56,98): f(98%56,56)=f(42,56)=f(56%42,42)=f(14,42)=f(42%14,14)=f(0,14)=14। आउटपुट: 14.
58
EN + हिं
GB What is the output: int f(int n){return (n==0||n==1)?n:f(n-1)+f(n-2);} cout<
IN आउटपुट क्या है: int f(int n){return (n==0||n==1)?n:f(n-1)+f(n-2);} cout
A
21 21
B
13 13
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fib: 0,1,1,2,3,5,8,13,21. f(8)=21. Output: 21.
व्याख्या (हिन्दी) फाइब: 0,1,1,2,3,5,8,13,21. एफ(8)=21. आउटपुट: 21.
59
EN + हिं
GB What is 'abbreviated function template' in C++20?
IN C++20 में 'संक्षिप्त फ़ंक्शन टेम्पलेट' क्या है?
A
void f(auto x) — shorthand for template<typename T> void f(T x) शून्य f(ऑटो x) - टेम्पलेट शून्य f(T x) के लिए आशुलिपि
B
Lambda shorthand लैम्ब्डा आशुलिपि
C
C++17 feature सी++17 सुविधा
D
Macro shorthand मैक्रो आशुलिपि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++20: void f(auto x){} is equivalent to template void f(T x){}.
व्याख्या (हिन्दी) C++20: void f(auto x){} टेम्पलेट void f(T x){} के बराबर है।
60
EN + हिं
GB What is the output: int f(int n,int k=1){return n?f(n-1,k*n):k;} cout<
IN आउटपुट क्या है: int f(int n,int k=1){return n?f(n-1,k*n):k;} cout
A
120 120
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Accumulates 5*4*3*2*1*1=120. Output: 120.
व्याख्या (हिन्दी) 5*4*3*2*1*1=120 जमा होता है। आउटपुट: 120.
46–60 of 132