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
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
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 = गलत का मूल्यांकन करता है)। अन्यथा निष्पादित करता है: एफ प्रिंट करता है।
17
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+ में तकनीकी रूप से अपरिभाषित व्यवहार है, लेकिन व्यवहार में प्रोग्राम हैंग हो जाता है।
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
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 मुद्रित हैं।
19
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.
व्याख्या (हिन्दी) डू-व्हाइल बॉडी को निष्पादित करने के बाद स्थिति की जांच करता है, इसलिए बॉडी हमेशा कम से कम एक बार निष्पादित होती है, भले ही शर्त शुरू में गलत हो।
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: कॉउट
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 से आता है)। ए प्रिंट करता है, फिर टूट जाता है।
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
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
22
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.
23
EN + हिं
GB What is the output: for(int i=0; i<3; i++) cout << i << ' '; cout << i;
IN आउटपुट क्या है: for(int i=0; i
A
0 1 2 3 0 1 2 3
B
0 1 2 0 1 2
C
Compile error संकलन त्रुटि
D
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 का उपयोग करना एक संकलन त्रुटि है।
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; } कैच (डबल डी) { कॉउट
A
D डी
B
I मैं
C
DI डि
D
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 प्रिंट करता है।
25
EN + हिं
GB What is the output: try { throw 42; } catch(double d) { cout<<'D'; } catch(int i) { cout<<'I'; }
IN आउटपुट क्या है: प्रयास करें {थ्रो 42; } कैच (डबल डी) { कॉउट
A
D डी
B
I मैं
C
DI डि
D
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 प्रिंट करता है।
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
A runtime conditional एक रनटाइम सशर्त
B
A compile-time conditional that discards untaken branch एक संकलन-समय सशर्त जो अप्रयुक्त शाखा को त्याग देता है
C
Replaces template specialization entirely टेम्पलेट विशेषज्ञता को पूरी तरह से बदल देता है
D
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.
व्याख्या (हिन्दी) यदि कॉन्स्टेक्सपीआर संकलन समय पर स्थिति का मूल्यांकन करता है; खारिज की गई शाखा को तत्काल नहीं किया गया है, जिससे टेम्प्लेट में प्रकार-विशिष्ट कोड की अनुमति मिलती है।
27
EN + हिं
GB What is 'if constexpr' in C++17?
IN C++17 में 'if constexpr' क्या है?
A
A runtime conditional एक रनटाइम सशर्त
B
A compile-time conditional that discards untaken branch एक संकलन-समय सशर्त जो अप्रयुक्त शाखा को त्याग देता है
C
Replaces template specialization entirely टेम्पलेट विशेषज्ञता को पूरी तरह से बदल देता है
D
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.
व्याख्या (हिन्दी) यदि कॉन्स्टेक्सपीआर संकलन समय पर स्थिति का मूल्यांकन करता है; खारिज की गई शाखा को तत्काल नहीं किया गया है, जिससे टेम्प्लेट में प्रकार-विशिष्ट कोड की अनुमति मिलती है।
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
A
5 5
B
3 3
C
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.
29
EN + हिं
GB What is the output: for(int i=0,j=10; i
IN आउटपुट क्या है: for(int i=0,j=10; i
A
A
B
B बी
C
AB अब
D
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 दोनों का मान समान है। डुप्लिकेट केस लेबल संकलन त्रुटि का कारण बनते हैं।
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
A
B
B बी
C
AB अब
D
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 दोनों का मान समान है। डुप्लिकेट केस लेबल संकलन त्रुटि का कारण बनते हैं।
16–30 of 133