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
106
EN + हिं
GB What is a 'range-based for loop' iteration over a raw array?
IN कच्चे सरणी पर 'लूप के लिए रेंज-आधारित' पुनरावृत्ति क्या है?
A
Iterates by pointer सूचक द्वारा पुनरावृत्त करता है
B
Iterates over each element प्रत्येक तत्व पर पुनरावृति करता है
C
Compile error संकलन त्रुटि
D
Only works with std containers केवल एसटीडी कंटेनरों के साथ काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Range-based for works on raw arrays as it knows their size at compile time: for(auto x: arr).
व्याख्या (हिन्दी) कच्चे सरणियों पर कार्यों के लिए रेंज-आधारित क्योंकि यह संकलन समय पर उनके आकार को जानता है: for(auto x: arr)।
107
EN + हिं
GB What is the output: int x=5; while(x (1, 6, 74, 4, 4, 'What happens when break is used inside a nested loop?', 'What happens when break is used inside a nested loop?', 'Breaks out of all loops', 'Breaks out of innermost loop only', 'Compile error', 'Compile error', 'Undefined behavior', 'undefined behavior', NULL, 'option_b', 'break only exits the immediately enclosing loop or switch; not outer loops.', 0, '2026-05-25', '2026-05-25'), (1, 6, 74, 4, 4, 'What is the output: switch(2.5){ case 2: cout
IN What is the output: int x=5; while(x (1, 6, 74, 4, 4, 'What happens when break is used inside a nested loop?', 'Nested loop के अंदर break use करने पर क्या होता है?', 'Breaks out of all loops', 'सभी loops से बाहर निकलता है', 'Breaks out of innermost loop only', 'केवल innermost loop से बाहर निकलता है', 'Compile error', 'Compile error', 'Undefined behavior', 'undefined behavior', NULL, 'option_b', 'break only exits the immediately enclosing loop or switch; not outer loops.', 0, '2026-05-25', '2026-05-25'), (1, 6, 74, 4, 4, 'What is the output: switch(2.5){ case 2: cout<<'A'; break; default: cout<<'B'; }
A
A
B
B बी
C
Compile error संकलन त्रुटि
D
AB अब
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Switch condition must be integer type; double is not allowed. Compile error.
व्याख्या (हिन्दी) स्विच की स्थिति पूर्णांक प्रकार की होनी चाहिए; डबल की अनुमति नहीं है. संकलन त्रुटि.
108
EN + हिं
GB What happens when break is used inside a nested loop?
IN क्या होता है जब नेस्टेड लूप के अंदर ब्रेक का उपयोग किया जाता है?
A
Breaks out of all loops सभी पाशों से टूट जाता है
B
Breaks out of innermost loop only अंतरतम पाश से ही टूटता है
C
Compile error संकलन त्रुटि
D
Undefined behavior अपरिभाषित व्यवहार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) break only exits the immediately enclosing loop or switch; not outer loops.
व्याख्या (हिन्दी) ब्रेक केवल तुरंत घेरने वाले लूप या स्विच से बाहर निकलता है; बाहरी लूप नहीं.
109
EN + हिं
GB What is the output: switch(2.5){ case 2: cout<<'A'; break; default: cout<<'B'; }
IN आउटपुट क्या है: स्विच (2.5) {केस 2: कॉउट
A
A
B
B बी
C
Compile error संकलन त्रुटि
D
AB अब
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Switch condition must be integer type; double is not allowed. Compile error.
व्याख्या (हिन्दी) स्विच की स्थिति पूर्णांक प्रकार की होनी चाहिए; डबल की अनुमति नहीं है. संकलन त्रुटि.
110
EN + हिं
GB What is the output: for(int i=1; i<=4; i*=2) cout<
IN आउटपुट क्या है: for(int i=1; i
A
1 2 4 1 2 4
B
1 2 3 4 1 2 3 4
C
2 4 2 4
D
1 4 1 4
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i=1 (print 1), i=2 (print 2), i=4 (print 4), i=8>4 stop. Output: 1 2 4.
व्याख्या (हिन्दी) i=1 (प्रिंट 1), i=2 (प्रिंट 2), i=4 (प्रिंट 4), i=8>4 स्टॉप। आउटपुट: 1 2 4.
111
EN + हिं
GB What is the output: int x=0; for(;x<5;) cout<
IN आउटपुट क्या है: int x=0; के लिये(;x
A
01234 01234
B
12345 12345
D
Infinite loop अनंत लूप
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Empty init and increment; x++ post-increment prints then increments. Prints 0,1,2,3,4.
व्याख्या (हिन्दी) खाली init और वेतन वृद्धि; x++ वृद्धि के बाद प्रिंट करता है और फिर वृद्धि करता है। 0,1,2,3,4 प्रिंट करता है।
112
EN + हिं
GB What does 'fallthrough' attribute do in C++17?
IN C++17 में 'फ़ॉलथ्रू' विशेषता क्या करती है?
A
Forces compiler to fall through switch cases कंपाइलर को स्विच केस से गुजरने के लिए बाध्य करता है
B
Suppresses warning about intentional fallthrough जानबूझकर गिरावट के बारे में चेतावनी को दबा देता है
C
Makes switch case mandatory स्विच केस को अनिवार्य बनाता है
D
Removes need for break ब्रेक की आवश्यकता को दूर करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) [[fallthrough]] suppresses the -Wimplicit-fallthrough compiler warning, indicating the fallthrough is intentional.
व्याख्या (हिन्दी) [[फ़ॉलथ्रू]] -विम्प्लिसिट-फ़ॉलथ्रू कंपाइलर चेतावनी को दबा देता है, जो दर्शाता है कि फ़ॉलथ्रू जानबूझकर किया गया है।
113
EN + हिं
GB What is the output: int i=5; for(i=0; i<3; i++) {} cout<
IN आउटपुट क्या है: int i=5; for(i=0; i
A
5 5
B
3 3
C
2 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i is declared outside for. After loop ends when i reaches 3, cout<
व्याख्या (हिन्दी) मैं के लिए बाहर घोषित किया गया है. लूप समाप्त होने के बाद जब मैं 3 तक पहुँचता हूँ, तो कॉउट
114
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
A
T टी
B
F एफ
C
TF टी.एफ
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=0 assigns 0 (evaluates to 0 = false). else executes: prints F.
व्याख्या (हिन्दी) x=0 0 निर्दिष्ट करता है (0 = गलत का मूल्यांकन करता है)। अन्यथा निष्पादित करता है: एफ प्रिंट करता है।
115
EN + हिं
GB What is the output of an infinite while(true) loop with no break?
IN बिना किसी ब्रेक के अनंत समय (सही) लूप का आउटपुट क्या है?
A
Nothing कुछ नहीं
B
Program hangs indefinitely कार्यक्रम अनिश्चित काल के लिए रुका हुआ है
C
Undefined behavior अपरिभाषित व्यवहार
D
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+ में तकनीकी रूप से अपरिभाषित व्यवहार है, लेकिन व्यवहार में प्रोग्राम हैंग हो जाता है।
116
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
A
01234 01234
B
13 13
C
024 024
D
02 02
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) continue skips even numbers. Odd numbers 1 and 3 are printed.
व्याख्या (हिन्दी) जारी रखें सम संख्याओं को छोड़ देता है। विषम संख्याएँ 1 और 3 मुद्रित हैं।
117
EN + हिं
GB What is the difference between while and do-while loops?
IN while और do-while लूप के बीच क्या अंतर है?
A
do-while executes body at least once डू-व्हाइल बॉडी को कम से कम एक बार निष्पादित करता है
B
while is faster जबकि तेज़ है
C
do-while requires break कार्य करते समय ब्रेक की आवश्यकता होती है
D
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.
व्याख्या (हिन्दी) डू-व्हाइल बॉडी को निष्पादित करने के बाद स्थिति की जांच करता है, इसलिए बॉडी हमेशा कम से कम एक बार निष्पादित होती है, भले ही शर्त शुरू में गलत हो।
118
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: कॉउट
A
AB अब
B
A
C
B बी
D
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 से आता है)। ए प्रिंट करता है, फिर टूट जाता है।
119
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
A
C सी
B
CC सीसी
C
Nothing कुछ नहीं
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i=2: 2*2=4<=10, 10%2==0, prints C and breaks.
व्याख्या (हिन्दी) मैं=2: 2*2=4
120
EN + हिं
GB What is the output: int x=0; while(x<3) { x++; if(x==2) break; } cout<
IN आउटपुट क्या है: int x=0; जबकि(x
A
3 3
B
2 2
C
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.
106–120 of 1915