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
1
EN + हिं
GB What is the output: for(int i=0;i<5;i++) if(i==3) continue; cout<
IN आउटपुट क्या है: for(int i=0;i
A
01245 01245
B
01234 01234
C
Compile error संकलन त्रुटि
D
0124 0124
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i is declared inside for; it's not accessible after the loop. Compile error.
व्याख्या (हिन्दी) i के लिए अंदर घोषित किया गया है; यह लूप के बाद पहुंच योग्य नहीं है। संकलन त्रुटि.
2
EN + हिं
GB What is the output: int x=10; switch(x){case 10: cout<<'A'; case 20: cout<<'B'; default: cout<<'C';}
IN आउटपुट क्या है: int x=10; स्विच(x){केस 10: कॉउट
A
A
B
ABC एबीसी
C
AB अब
D
AC ए.सी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Without break statements, execution falls through all subsequent cases after matching case 10. Output: ABC.
व्याख्या (हिन्दी) ब्रेक स्टेटमेंट के बिना, केस 10 के मिलान के बाद सभी बाद के मामलों में निष्पादन गिर जाता है। आउटपुट: एबीसी।
3
EN + हिं
GB What does 'goto' do in C++?
IN C++ में 'goto' क्या करता है?
A
Jumps to a labeled statement एक लेबल किए गए कथन पर चला जाता है
B
Is removed in C++11 C++11 में हटा दिया गया है
C
Only works inside loops केवल लूप के अंदर काम करता है
D
Causes undefined behavior अपरिभाषित व्यवहार का कारण बनता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) goto transfers control to a named label within the same function. It is legal but considered poor style.
व्याख्या (हिन्दी) goto transfers control to a named label within the same function. यह कानूनी है लेकिन ख़राब शैली मानी जाती है।
4
EN + हिं
GB What is the output: int i=0; do{ cout<
IN आउटपुट क्या है: int i=0; करो {मुफ़्त करो
A
Nothing कुछ नहीं
C
01 01
D
Infinite loop अनंत लूप
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) do-while executes body at least once. Prints i=0, then i becomes 1, condition 1<0 is false, loop exits.
व्याख्या (हिन्दी) डू-व्हाइल बॉडी को कम से कम एक बार निष्पादित करता है। i=0 प्रिंट करता है, फिर i 1 हो जाता है, शर्त 1
5
EN + हिं
GB What is the output: for(;;) { static int x=0; cout<2) break; }
IN आउटपुट क्या है: for(;;) {static int x=0; अदालत
A
012 012
C
123 123
D
Infinite loop अनंत लूप
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Static x persists; loop: print 0, x=1; print 1, x=2; print 2, x=3, 3>2 break. Output: 012.
व्याख्या (हिन्दी) स्थैतिक x कायम रहता है; लूप: प्रिंट 0, x=1; प्रिंट 1, x=2; प्रिंट 2, x=3, 3>2 ​​ब्रेक। आउटपुट: 012.
6
EN + हिं
GB What is the output: int x=5; if(x>3) if(x>4) cout<<'A'; else cout<<'B';
IN आउटपुट क्या है: int x=5; if(x>3) if(x>4) cout
A
A
B
B बी
C
AB अब
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Dangling else: else binds to nearest if. x>4 is true so 'A' is printed.
व्याख्या (हिन्दी) डैंगलिंग अन्य: अन्यथा निकटतम यदि से जुड़ता है। x>4 सत्य है इसलिए 'ए' मुद्रित है।
7
EN + हिं
GB What is the output: for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(i==j) goto done; done: cout<<'X';
IN आउटपुट क्या है: for(int i=0;i
A
X एक्स
B
XXX XXX
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) When i==0 and j==0, goto jumps to done label, printing X once.
व्याख्या (हिन्दी) जब i==0 और j==0, गोटो पूर्ण लेबल पर चला जाता है, X को एक बार प्रिंट करता है।
8
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)।
9
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.
व्याख्या (हिन्दी) स्विच की स्थिति पूर्णांक प्रकार की होनी चाहिए; डबल की अनुमति नहीं है. संकलन त्रुटि.
10
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.
व्याख्या (हिन्दी) ब्रेक केवल तुरंत घेरने वाले लूप या स्विच से बाहर निकलता है; बाहरी लूप नहीं.
11
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.
व्याख्या (हिन्दी) स्विच की स्थिति पूर्णांक प्रकार की होनी चाहिए; डबल की अनुमति नहीं है. संकलन त्रुटि.
12
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.
13
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 प्रिंट करता है।
14
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.
व्याख्या (हिन्दी) [[फ़ॉलथ्रू]] -विम्प्लिसिट-फ़ॉलथ्रू कंपाइलर चेतावनी को दबा देता है, जो दर्शाता है कि फ़ॉलथ्रू जानबूझकर किया गया है।
15
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 तक पहुँचता हूँ, तो कॉउट
1–15 of 133