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 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
61220 61220
Compile error संकलन त्रुटि
Undefined अपरिभाषित
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.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 47

EN + हिं
GB What is 'std::invoke_result_t'?
IN 'std::invoke_result_t' क्या है?
Type of result of invoking callable with args आर्गों के साथ कॉल करने योग्य को लागू करने के परिणाम का प्रकार
Same as decltype डिक्ल्टाइप के समान
Runtime type रनटाइम प्रकार
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...) का रिटर्न प्रकार देता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 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?
noexcept move constructor enables std::vector to move instead of copy on reallocation noexcept मूव कंस्ट्रक्टर std::vector को पुन:आवंटन पर कॉपी करने के बजाय स्थानांतरित करने में सक्षम बनाता है
No relation कोई संबंध नहीं
Makes moves faster तेजी से कदम बढ़ाता है
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 मूव कंस्ट्रक्टर का उपयोग केवल तभी करता है जब यह कोई अपवाद न हो; अन्यथा अपवाद सुरक्षा के लिए प्रतिलिपि पर वापस आ जाता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 49

EN + हिं
GB What is 'noexcept' function and move semantics?
IN 'नोएक्सेप्ट' फ़ंक्शन और मूव सिमेंटिक्स क्या है?
noexcept move constructor enables std::vector to move instead of copy on reallocation noexcept मूव कंस्ट्रक्टर std::vector को पुन:आवंटन पर कॉपी करने के बजाय स्थानांतरित करने में सक्षम बनाता है
No relation कोई संबंध नहीं
Makes moves faster तेजी से कदम बढ़ाता है
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 मूव कंस्ट्रक्टर का उपयोग केवल तभी करता है जब यह कोई अपवाद न हो; अन्यथा अपवाद सुरक्षा के लिए प्रतिलिपि पर वापस आ जाता है।
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 50

EN + हिं
GB What is the output: auto f=[](auto x,auto y){return x
IN आउटपुट क्या है: ऑटो f=[](ऑटो x,ऑटो y){रिटर्न x
32.0 32.0
Compile error संकलन त्रुटि
35 35
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.
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Functions" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 51

EN + हिं
GB What is 'overloading vs overriding'?
IN 'ओवरलोडिंग बनाम ओवरराइडिंग' क्या है?
Overloading: same name diff params; overriding: replaces virtual ओवरलोडिंग: समान नाम भिन्न पैरामीटर; ओवरराइडिंग: वर्चुअल को प्रतिस्थापित करता है
Same thing एक ही बात
Overriding is compile-time ओवरराइडिंग संकलन-समय है
Overloading is runtime ओवरलोडिंग रनटाइम है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Overloading is compile-time selection by signature; overriding is runtime dispatch via vtable.
व्याख्या (हिन्दी) ओवरलोडिंग हस्ताक्षर द्वारा संकलन-समय चयन है; ओवरराइडिंग vtable के माध्यम से रनटाइम प्रेषण है।
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Functions" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

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

Question 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); अदालत
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5+4+3+2+1=15. Output: 15.
व्याख्या (हिन्दी) 5+4+3+2+1=15. आउटपुट: 15.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 54

EN + हिं
GB What is 'std::transform_reduce'?
IN 'std::transform_reduce' क्या है?
Map then reduce: apply transform then reduction मानचित्र फिर कम करें: परिवर्तन लागू करें फिर कमी करें
Same as inner_product आंतरिक_उत्पाद के समान
Parallel sort समानांतर प्रकार
A filter+map एक फ़िल्टर+मानचित्र
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) transform_reduce applies a unary op to elements then reduces; parallel version of inner_product.
व्याख्या (हिन्दी) ट्रांसफ़ॉर्म_रिड्यूस तत्वों पर एक यूनरी ऑप लागू करता है और फिर कम कर देता है; इनर_प्रोडक्ट का समानांतर संस्करण।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

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

Question 56

EN + हिं
GB What is 'trailing requires clause' in C++20?
IN C++20 में 'ट्रेलिंग रिक्वायर्ड क्लॉज' क्या है?
auto f(T x) requires Concept<T> — constrains template ऑटो f(T x) के लिए संकल्पना - बाधा टेम्पलेट की आवश्यकता होती है
Same as enable_if Enable_if के समान
Runtime check रनटाइम जांच
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 की तुलना में अधिक साफ़।
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Functions" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

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

Question 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
21 21
13 13
Compile error संकलन त्रुटि
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.
🎯 Exam Perspective
OOP Using C++ ("Functions" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 59

EN + हिं
GB What is 'abbreviated function template' in C++20?
IN C++20 में 'संक्षिप्त फ़ंक्शन टेम्पलेट' क्या है?
void f(auto x) — shorthand for template<typename T> void f(T x) शून्य f(ऑटो x) - टेम्पलेट शून्य f(T x) के लिए आशुलिपि
Lambda shorthand लैम्ब्डा आशुलिपि
C++17 feature सी++17 सुविधा
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){} के बराबर है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Functions" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 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
120 120
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Accumulates 5*4*3*2*1*1=120. Output: 120.
व्याख्या (हिन्दी) 5*4*3*2*1*1=120 जमा होता है। आउटपुट: 120.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Functions" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।