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
121
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 का उपयोग करना एक संकलन त्रुटि है।
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; } कैच (डबल डी) { कॉउट
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 प्रिंट करता है।
123
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 प्रिंट करता है।
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
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.
व्याख्या (हिन्दी) यदि कॉन्स्टेक्सपीआर संकलन समय पर स्थिति का मूल्यांकन करता है; खारिज की गई शाखा को तत्काल नहीं किया गया है, जिससे टेम्प्लेट में प्रकार-विशिष्ट कोड की अनुमति मिलती है।
125
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.
व्याख्या (हिन्दी) यदि कॉन्स्टेक्सपीआर संकलन समय पर स्थिति का मूल्यांकन करता है; खारिज की गई शाखा को तत्काल नहीं किया गया है, जिससे टेम्प्लेट में प्रकार-विशिष्ट कोड की अनुमति मिलती है।
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
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.
127
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 दोनों का मान समान है। डुप्लिकेट केस लेबल संकलन त्रुटि का कारण बनते हैं।
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
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 दोनों का मान समान है। डुप्लिकेट केस लेबल संकलन त्रुटि का कारण बनते हैं।
129
EN + हिं
GB What is the output: int x=5; if(x) { int x=10; cout<
IN आउटपुट क्या है: int x=5; यदि(x) { int x=10; अदालत
A
105 105
B
1010 1010
C
55 55
D
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.
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; } कोउट
A
3 5 7 3 5 7
B
357 357
C
Compile error संकलन त्रुटि
D
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.
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; एफ(ए); अदालत
A
5 5
B
10 10
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f takes a reference to int; modifying x modifies a. Output: 10.
व्याख्या (हिन्दी) f int का संदर्भ लेता है; x को संशोधित करने से a संशोधित हो जाता है। आउटपुट: 10.
132
EN + हिं
GB What is 'function overload resolution' in C++?
IN C++ में 'फ़ंक्शन ओवरलोड रिज़ॉल्यूशन' क्या है?
A
Choosing the best matching overload at compile time संकलन समय पर सर्वोत्तम मिलान अधिभार का चयन करना
B
Resolving function calls at runtime रनटाइम पर फ़ंक्शन कॉल का समाधान करना
C
Template deduction टेम्पलेट कटौती
D
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.
व्याख्या (हिन्दी) ओवरलोड रिज़ॉल्यूशन संकलन समय पर होता है: कंपाइलर तर्क प्रकारों के आधार पर उम्मीदवारों के एक सेट से सबसे अच्छे मिलान फ़ंक्शन का चयन करता है।
133
EN + हिं
GB What is a lambda closure in C++?
IN C++ में लैम्ब्डा क्लोजर क्या है?
A
A function pointer एक फ़ंक्शन सूचक
B
An anonymous function object that can capture local variables एक अनाम फ़ंक्शन ऑब्जेक्ट जो स्थानीय चर को कैप्चर कर सकता है
C
A virtual function एक आभासी कार्य
D
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.
व्याख्या (हिन्दी) लैम्ब्डा एक क्लोजर ऑब्जेक्ट (अनाम वर्ग) बनाता है जो आसपास के स्थानीय चर को कैप्चर करता है और ऑपरेटर() को परिभाषित करता है।
134
EN + हिं
GB What is the output: int f(){ static int x=0; return ++x; } cout<
IN आउटपुट क्या है: int f(){static int x=0; वापसी++x; } कोउट
A
111 111
B
123 123
C
Unspecified अनिर्दिष्ट
D
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, तर्कों के मूल्यांकन का क्रम
135
EN + हिं
GB What is 'tail call optimization'?
IN 'टेल कॉल ऑप्टिमाइज़ेशन' क्या है?
A
Optimizing the last statement अंतिम कथन का अनुकूलन
B
Reusing the caller's stack frame for a tail-recursive call टेल-रिकर्सिव कॉल के लिए कॉलर के स्टैक फ़्रेम का पुन: उपयोग करना
C
Inlining recursive functions पुनरावर्ती कार्यों को इनलाइन करना
D
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++ मानक द्वारा इसकी गारंटी नहीं है लेकिन कई कंपाइलरों द्वारा इसकी गारंटी दी गई है।
121–135 of 1915