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

Question 121

EN + हिं
GB What is the output: for(int i=0; i<3; i++) cout << i << ' '; cout << i;
IN आउटपुट क्या है: for(int i=0; i
0 1 2 3 0 1 2 3
0 1 2 0 1 2
Compile error संकलन त्रुटि
0 1 2 2 0 1 2 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i is scoped inside the for loop. Using i outside the loop is a compile error.
व्याख्या (हिन्दी) i का दायरा for लूप के अंदर है। लूप के बाहर i का उपयोग करना एक संकलन त्रुटि है।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 122

EN + हिं
GB What is the output: int i=1; for(; i; i (1, 6, 74, 4, 4, 'What is the output: try { throw 42; } catch(double d) { cout<<'D'; } catch(int i) { cout<<'I'; }
IN आउटपुट क्या है: int i=1; for(; i; i (1, 6, 74, 4, 4, 'आउटपुट क्या है: प्रयास करें {थ्रो 42; } कैच (डबल डी) { कॉउट
D डी
I मैं
DI डि
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42 is int; catch handlers are tried in order; int matches second handler, prints I.
व्याख्या (हिन्दी) 42 पूर्णांक है; कैच हैंडलर्स को क्रम में आज़माया जाता है; int दूसरे हैंडलर से मेल खाता है, I प्रिंट करता है।
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 123

EN + हिं
GB What is the output: try { throw 42; } catch(double d) { cout<<'D'; } catch(int i) { cout<<'I'; }
IN आउटपुट क्या है: प्रयास करें {थ्रो 42; } कैच (डबल डी) { कॉउट
D डी
I मैं
DI डि
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42 is int; catch handlers are tried in order; int matches second handler, prints I.
व्याख्या (हिन्दी) 42 पूर्णांक है; कैच हैंडलर्स को क्रम में आज़माया जाता है; int दूसरे हैंडलर से मेल खाता है, I प्रिंट करता है।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 124

EN + हिं
GB What is the output: int x=5; for(int i=0;i
IN आउटपुट क्या है: int x=5; for(int i=0;i
A runtime conditional एक रनटाइम सशर्त
A compile-time conditional that discards untaken branch एक संकलन-समय सशर्त जो अप्रयुक्त शाखा को त्याग देता है
Replaces template specialization entirely टेम्पलेट विशेषज्ञता को पूरी तरह से बदल देता है
Only works with integers केवल पूर्णांकों के साथ काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) if constexpr evaluates condition at compile time; the discarded branch is not instantiated, allowing type-specific code in templates.
व्याख्या (हिन्दी) यदि कॉन्स्टेक्सपीआर संकलन समय पर स्थिति का मूल्यांकन करता है; खारिज की गई शाखा को तत्काल नहीं किया गया है, जिससे टेम्प्लेट में प्रकार-विशिष्ट कोड की अनुमति मिलती है।
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 125

EN + हिं
GB What is 'if constexpr' in C++17?
IN C++17 में 'if constexpr' क्या है?
A runtime conditional एक रनटाइम सशर्त
A compile-time conditional that discards untaken branch एक संकलन-समय सशर्त जो अप्रयुक्त शाखा को त्याग देता है
Replaces template specialization entirely टेम्पलेट विशेषज्ञता को पूरी तरह से बदल देता है
Only works with integers केवल पूर्णांकों के साथ काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) if constexpr evaluates condition at compile time; the discarded branch is not instantiated, allowing type-specific code in templates.
व्याख्या (हिन्दी) यदि कॉन्स्टेक्सपीआर संकलन समय पर स्थिति का मूल्यांकन करता है; खारिज की गई शाखा को तत्काल नहीं किया गया है, जिससे टेम्प्लेट में प्रकार-विशिष्ट कोड की अनुमति मिलती है।
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 126

EN + हिं
GB What is the output: int i=0; for(i=0;i<5;++i) if(i==3) goto end; end: cout<
IN आउटपुट क्या है: int i=0; for(i=0;i
5 5
3 3
4 4
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) When i==3, goto end jumps out of loop to label. cout prints i=3.
व्याख्या (हिन्दी) जब i==3, गोटो एंड लूप से बाहर लेबल पर चला जाता है। कोउट प्रिंट i=3.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 127

EN + हिं
GB What is the output: for(int i=0,j=10; i
IN आउटपुट क्या है: for(int i=0,j=10; i
A
B बी
AB अब
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Both case 1+1 (=2) and case 2 have the same value. Duplicate case labels cause a compile error.
व्याख्या (हिन्दी) स्थिति 1+1 (=2) और स्थिति 2 दोनों का मान समान है। डुप्लिकेट केस लेबल संकलन त्रुटि का कारण बनते हैं।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 128

EN + हिं
GB What is the output: int x=2; switch(x){ case 1+1: cout<<'A'; break; case 2: cout<<'B'; break; }
IN आउटपुट क्या है: int x=2; स्विच(x){केस 1+1: कॉउट
A
B बी
AB अब
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Both case 1+1 (=2) and case 2 have the same value. Duplicate case labels cause a compile error.
व्याख्या (हिन्दी) स्थिति 1+1 (=2) और स्थिति 2 दोनों का मान समान है। डुप्लिकेट केस लेबल संकलन त्रुटि का कारण बनते हैं।
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 129

EN + हिं
GB What is the output: int x=5; if(x) { int x=10; cout<
IN आउटपुट क्या है: int x=5; यदि(x) { int x=10; अदालत
105 105
1010 1010
55 55
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inner block has its own x=10 (shadows outer). Prints 10 inside block, then outer x=5. Output: 105.
व्याख्या (हिन्दी) आंतरिक ब्लॉक का अपना x=10 (बाहरी छाया) होता है। ब्लॉक के अंदर 10 प्रिंट करता है, फिर बाहरी x=5 प्रिंट करता है। आउटपुट: 105.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 130

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; } कोउट
3 5 7 3 5 7
357 357
Compile error संकलन त्रुटि
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.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 131

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; एफ(ए); अदालत
5 5
10 10
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f takes a reference to int; modifying x modifies a. Output: 10.
व्याख्या (हिन्दी) f int का संदर्भ लेता है; x को संशोधित करने से a संशोधित हो जाता है। आउटपुट: 10.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 132

EN + हिं
GB What is 'function overload resolution' in C++?
IN C++ में 'फ़ंक्शन ओवरलोड रिज़ॉल्यूशन' क्या है?
Choosing the best matching overload at compile time संकलन समय पर सर्वोत्तम मिलान अधिभार का चयन करना
Resolving function calls at runtime रनटाइम पर फ़ंक्शन कॉल का समाधान करना
Template deduction टेम्पलेट कटौती
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.
व्याख्या (हिन्दी) ओवरलोड रिज़ॉल्यूशन संकलन समय पर होता है: कंपाइलर तर्क प्रकारों के आधार पर उम्मीदवारों के एक सेट से सबसे अच्छे मिलान फ़ंक्शन का चयन करता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 133

EN + हिं
GB What is a lambda closure in C++?
IN C++ में लैम्ब्डा क्लोजर क्या है?
A function pointer एक फ़ंक्शन सूचक
An anonymous function object that can capture local variables एक अनाम फ़ंक्शन ऑब्जेक्ट जो स्थानीय चर को कैप्चर कर सकता है
A virtual function एक आभासी कार्य
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.
व्याख्या (हिन्दी) लैम्ब्डा एक क्लोजर ऑब्जेक्ट (अनाम वर्ग) बनाता है जो आसपास के स्थानीय चर को कैप्चर करता है और ऑपरेटर() को परिभाषित करता है।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 134

EN + हिं
GB What is the output: int f(){ static int x=0; return ++x; } cout<
IN आउटपुट क्या है: int f(){static int x=0; वापसी++x; } कोउट
111 111
123 123
Unspecified अनिर्दिष्ट
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, तर्कों के मूल्यांकन का क्रम
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 135

EN + हिं
GB What is 'tail call optimization'?
IN 'टेल कॉल ऑप्टिमाइज़ेशन' क्या है?
Optimizing the last statement अंतिम कथन का अनुकूलन
Reusing the caller's stack frame for a tail-recursive call टेल-रिकर्सिव कॉल के लिए कॉलर के स्टैक फ़्रेम का पुन: उपयोग करना
Inlining recursive functions पुनरावर्ती कार्यों को इनलाइन करना
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++ मानक द्वारा इसकी गारंटी नहीं है लेकिन कई कंपाइलरों द्वारा इसकी गारंटी दी गई है।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।