OOP Using C++ — MCQ Practice

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

📚 163 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
163 questions
1
EN + हिं
GB What is the output: int a=5,b=3; cout<<(a&b)<<' '<<(a|b)<<' '<<(a^b);
IN आउटपुट क्या है: int a=5,b=3; अदालत
A
1 7 6 1 7 6
B
3 5 6 3 5 6
C
5 3 1 5 3 1
D
0 7 6 0 7 6
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5=101, 3=011. AND=001=1, OR=111=7, XOR=110=6.
व्याख्या (हिन्दी) 5=101, 3=011. और=001=1, या=111=7, एक्सओआर=110=6।
2
EN + हिं
GB What does the spaceship operator <=> return in C++20?
IN C++20 में स्पेसशिप ऑपरेटर क्या लौटाता है?
A
bool बूल
B
int (-1, 0, 1) पूर्णांक (-1, 0, 1)
C
std::strong_ordering or similar std::strong_ordering या समान
D
void खालीपन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The <=> operator returns a comparison category type: std::strong_ordering, std::weak_ordering, or std::partial_ordering.
व्याख्या (हिन्दी) ऑपरेटर एक तुलना श्रेणी प्रकार लौटाता है: std::strong_ordering, std::weak_ordering, या std::partial_ordering।
3
EN + हिं
GB What is the output: int x=5; cout<<(x>>1)<<' '<<(x<<1);
IN आउटपुट क्या है: int x=5; cout1)
A
2 10 2 10
B
2 20 2 20
C
3 10 3 10
D
1 10 1 10
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5>>1 = 2 (right shift divides by 2), 5<<1 = 10 (left shift multiplies by 2).
व्याख्या (हिन्दी) 5>>1 = 2 (दाहिनी पारी 2 से विभाजित होती है), 5
4
EN + हिं
GB What is operator precedence for: a + b * c - d / e?
IN ए + बी * सी - डी / ई के लिए ऑपरेटर प्राथमिकता क्या है?
A
Left to right बाएं से दायां
B
a + (b * c) - (d / e) ए + (बी * सी) - (डी / ई)
C
(a + b) * (c - d) / e (ए + बी) * (सी - डी) / ई
D
(a + b) * c - d / e (ए + बी) * सी - डी / ई
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) * and / have higher precedence than + and -, evaluated left to right among same precedence.
व्याख्या (हिन्दी) * और / की प्राथमिकता + और - से अधिक है, उसी प्राथमिकता के बीच बाएं से दाएं मूल्यांकन किया जाता है।
5
EN + हिं
GB What is the output: int x=10; cout << (x>5 && x++>9) << ' ' << x;
IN आउटपुट क्या है: int x=10; कॉउट 5 && x++>9)
A
1 11 1 11
B
0 10 0 10
C
1 10 1 10
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x>5 is true, so right side evaluates: x++(returns 10)>9 is true, x becomes 11. Output: 1 11.
व्याख्या (हिन्दी) x>5 सत्य है, इसलिए दाहिना पक्ष मूल्यांकन करता है: x++(रिटर्न 10)>9 सत्य है, x 11 हो जाता है। आउटपुट: 1 11।
6
EN + हिं
GB What does operator-> overloading enable?
IN ऑपरेटर-> ओवरलोडिंग क्या सक्षम करती है?
A
Custom pointer dereferencing कस्टम पॉइंटर डीरेफ़रेंसिंग
B
Array access ऐरे पहुंच
C
Function call syntax फ़ंक्शन कॉल सिंटैक्स
D
Type conversion रूपांतरण टाइप करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Overloading -> enables smart pointer behavior — the operator should return a raw pointer or another object that has -> defined.
व्याख्या (हिन्दी) ओवरलोडिंग -> स्मार्ट पॉइंटर व्यवहार को सक्षम बनाता है - ऑपरेटर को एक कच्चा पॉइंटर या कोई अन्य ऑब्जेक्ट लौटाना चाहिए जिसमें -> परिभाषित हो।
7
EN + हिं
GB What is the output: cout << (3,5,7);
IN आउटपुट क्या है: cout
A
3 3
B
5 5
C
7 7
D
357 357
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The comma operator evaluates left to right and returns the last value: (3,5,7) = 7.
व्याख्या (हिन्दी) अल्पविराम ऑपरेटर बाएं से दाएं मूल्यांकन करता है और अंतिम मान लौटाता है: (3,5,7) = 7।
8
EN + हिं
GB What is the result: int a=2; int b = a<<2 + 1;
IN परिणाम क्या है: int a=2; पूर्णांक बी = ए
A
9 9
B
10 10
C
16 16
D
8 8
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) + has higher precedence than <<, so a<<(2+1) = 2<<3 = 16.
व्याख्या (हिन्दी) + की तुलना में अधिक प्राथमिकता है
9
EN + हिं
GB What is short-circuit evaluation in C++?
IN C++ में शॉर्ट-सर्किट मूल्यांकन क्या है?
A
Compiler skips dead code कंपाइलर डेड कोड को छोड़ देता है
B
&& and || skip right operand if result determined from left && और || यदि परिणाम बाएँ से निर्धारित होता है तो दाएँ ऑपरेंड को छोड़ें
C
Only applies to bitwise operators केवल बिटवाइज़ ऑपरेटरों पर लागू होता है
D
Template specialization optimization टेम्पलेट विशेषज्ञता अनुकूलन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) In &&, if left is false, right is not evaluated. In ||, if left is true, right is not evaluated.
व्याख्या (हिन्दी) && में, यदि बायाँ असत्य है, तो दाएँ का मूल्यांकन नहीं किया जाता है। || में, यदि बायाँ सत्य है, तो दाएँ का मूल्यांकन नहीं किया जाता है।
10
EN + हिं
GB What is the output: int x=5; x+=x-=x*=2; cout<
IN आउटपुट क्या है: int x=5; x+=x-=x*=2; अदालत
B
5 5
C
10 10
D
Undefined behavior अपरिभाषित व्यवहार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Multiple assignments to x with reads in the same expression without sequencing is undefined behavior in C++ (pre-C++17).
व्याख्या (हिन्दी) अनुक्रमण के बिना एक ही अभिव्यक्ति में पढ़ने के साथ x को एकाधिक असाइनमेंट C++ (प्री-C++17) में अपरिभाषित व्यवहार है।
11
EN + हिं
GB What is the output: int a=10,b=5; cout<<(a>b?a:b);
IN आउटपुट क्या है: int a=10,b=5; अदालत
A
5 5
B
10 10
C
15 15
D
1 1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a>b is true (10>5), so ternary returns a=10.
व्याख्या (हिन्दी) a>b सत्य है (10>5), इसलिए टर्नरी a=10 लौटाता है।
12
EN + हिं
GB What is the output: cout << ~0;
IN आउटपुट क्या है: cout
B
-1 -1
C
1 1
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ~0 is bitwise NOT of 0: all bits flipped = 0xFFFFFFFF = -1 in two's complement.
व्याख्या (हिन्दी) ~0 बिटवाइज़ है, 0 में से नहीं: सभी बिट फ़्लिप = 0xFFFFFFFF = -1 दो के पूरक में।
13
EN + हिं
GB Which operator has the lowest precedence in C++?
IN C++ में किस ऑपरेटर की प्राथमिकता सबसे कम है?
A
= =
B
|| ||
C
?: ?:
D
throw फेंक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) throw expression has the lowest precedence among operators in C++.
व्याख्या (हिन्दी) C++ में ऑपरेटरों के बीच थ्रो एक्सप्रेशन की प्राथमिकता सबसे कम है।
14
EN + हिं
GB What is the output: int x=6; cout<<(x%4)<<' '<<(-x%4);
IN आउटपुट क्या है: int x=6; अदालत
A
2 -2 2 -2
B
2 2 2 2
C
2 -1 2 -1
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 6%4=2. In C++11+, the result of % has the same sign as the dividend: -6%4 = -2.
व्याख्या (हिन्दी) 6%4=2. C++11+ में, % के परिणाम में लाभांश के समान चिह्न होता है: -6%4 = -2।
15
EN + हिं
GB What is the output: int a=1; cout << a (1, 6, 73, 3, 4, 'What does the 'delete' operator do when called on a null pointer?
IN आउटपुट क्या है: int a=1; अदालत
A
Undefined behavior अपरिभाषित व्यवहार
B
Segfault सेगफॉल्ट
C
Nothing (safe) कुछ भी नहीं (सुरक्षित)
D
Throws exception अपवाद फेंकता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The C++ standard guarantees that delete on a null pointer is a no-op; it is safe to delete nullptr.
व्याख्या (हिन्दी) C++ मानक गारंटी देता है कि शून्य पॉइंटर पर डिलीट करना नो-ऑप है; nullptr को हटाना सुरक्षित है।
1–15 of 163