OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye.

📚 133 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
133 questions

Question 16

EN + हिं
GB What is the output: int x=1; if(x=0) cout<<'T'; else cout<<'F';
IN आउटपुट क्या है: int x=1; if(x=0) cout
T टी
F एफ
TF टी.एफ
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=0 assigns 0 (evaluates to 0 = false). else executes: prints F.
व्याख्या (हिन्दी) x=0 0 निर्दिष्ट करता है (0 = गलत का मूल्यांकन करता है)। अन्यथा निष्पादित करता है: एफ प्रिंट करता है।
🎯 Exam Perspective
OOP Using C++ ("Control Statements" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 17

EN + हिं
GB What is the output of an infinite while(true) loop with no break?
IN बिना किसी ब्रेक के अनंत समय (सही) लूप का आउटपुट क्या है?
Nothing कुछ नहीं
Program hangs indefinitely कार्यक्रम अनिश्चित काल के लिए रुका हुआ है
Undefined behavior अपरिभाषित व्यवहार
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) An infinite loop with no observable side effects is technically undefined behavior in C++11+, but in practice the program hangs.
व्याख्या (हिन्दी) बिना किसी प्रत्यक्ष दुष्प्रभाव वाला एक अनंत लूप C++11+ में तकनीकी रूप से अपरिभाषित व्यवहार है, लेकिन व्यवहार में प्रोग्राम हैंग हो जाता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Control Statements" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 18

EN + हिं
GB What is the output: for(int i=0;i<5;i++) { if(i%2==0) continue; cout<
IN आउटपुट क्या है: for(int i=0;i
01234 01234
13 13
024 024
02 02
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) continue skips even numbers. Odd numbers 1 and 3 are printed.
व्याख्या (हिन्दी) जारी रखें सम संख्याओं को छोड़ देता है। विषम संख्याएँ 1 और 3 मुद्रित हैं।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Control Statements" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 19

EN + हिं
GB What is the difference between while and do-while loops?
IN while और do-while लूप के बीच क्या अंतर है?
do-while executes body at least once डू-व्हाइल बॉडी को कम से कम एक बार निष्पादित करता है
while is faster जबकि तेज़ है
do-while requires break कार्य करते समय ब्रेक की आवश्यकता होती है
No difference कोई फर्क नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) do-while checks condition after executing body, so body always executes at least once even if condition is false initially.
व्याख्या (हिन्दी) डू-व्हाइल बॉडी को निष्पादित करने के बाद स्थिति की जांच करता है, इसलिए बॉडी हमेशा कम से कम एक बार निष्पादित होती है, भले ही शर्त शुरू में गलत हो।
🎯 Exam Perspective
OOP Using C++ ("Control Statements" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 20

EN + हिं
GB What is the output: int x=3; switch(x) { case 1: case 2: case 3: cout<<'A'; break; default: cout<<'B'; }
IN आउटपुट क्या है: int x=3; स्विच(x) { केस 1: केस 2: केस 3: कॉउट
AB अब
A
B बी
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=3 matches case 3 (which falls through from case 1 and 2). Prints A, then breaks.
व्याख्या (हिन्दी) x=3 केस 3 से मेल खाता है (जो केस 1 और 2 से आता है)। ए प्रिंट करता है, फिर टूट जाता है।
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Control Statements" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 21

EN + हिं
GB What is the output: int n=10; for(int i=2; i*i<=n; i++) if(n%i==0) { cout<<'C'; break; }
IN आउटपुट क्या है: int n=10; for(int i=2; i*i
C सी
CC सीसी
Nothing कुछ नहीं
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i=2: 2*2=4<=10, 10%2==0, prints C and breaks.
व्याख्या (हिन्दी) मैं=2: 2*2=4
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ ("Control Statements" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 22

EN + हिं
GB What is the output: int x=0; while(x<3) { x++; if(x==2) break; } cout<
IN आउटपुट क्या है: int x=0; जबकि(x
3 3
2 2
1 1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x goes 0->1, then 1->2, break at x==2. cout prints 2.
व्याख्या (हिन्दी) x 0->1 जाता है, फिर 1->2, x==2 पर टूटता है। कॉउट प्रिंट्स 2.
🎯 Exam Perspective
OOP Using C++ ("Control Statements" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 23

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++ ("Control Statements" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 24

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
यह प्रश्न OOP Using C++ ("Control Statements" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 25

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
OOP Using C++ ("Control Statements" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 26

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
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ ("Control Statements" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 27

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
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ ("Control Statements" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 28

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++ ("Control Statements" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 29

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++ ("Control Statements" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 30

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
यह प्रश्न OOP Using C++ ("Control Statements" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।