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
76
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) में अपरिभाषित व्यवहार है।
77
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 लौटाता है।
78
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 दो के पूरक में।
79
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++ में ऑपरेटरों के बीच थ्रो एक्सप्रेशन की प्राथमिकता सबसे कम है।
80
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।
81
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 को हटाना सुरक्षित है।
82
EN + हिं
GB What does the 'delete' operator do when called on a null pointer?
IN शून्य पॉइंटर पर कॉल करने पर 'डिलीट' ऑपरेटर क्या करता है?
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 को हटाना सुरक्षित है।
83
EN + हिं
GB What is operator[] overloaded for in std::vector?
IN std::vector में ऑपरेटर[] ओवरलोडेड क्या है?
A
Bounds-checked element access सीमा-जांचित तत्व पहुंच
B
Unchecked element access by index सूचकांक द्वारा अनियंत्रित तत्व पहुंच
C
Slice operation स्लाइस ऑपरेशन
D
Iterator creation पुनरावर्तक निर्माण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::vector::operator[] provides unchecked access; use .at() for bounds-checked access.
व्याख्या (हिन्दी) std::vector::operator[] अनियंत्रित पहुंच प्रदान करता है; सीमा-जांचित पहुंच के लिए .at() का उपयोग करें।
84
EN + हिं
GB What is the output: int x=0; cout<<(x=5)<<' '<<(x==5);
IN आउटपुट क्या है: int x=0; अदालत
A
5 1 5 1
B
0 0 0 0
C
5 0 5 0
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (x=5) assigns 5 to x and returns 5. Then x==5 is true=1. Output: 5 1.
व्याख्या (हिन्दी) (x=5) x को 5 निर्दिष्ट करता है और 5 लौटाता है। तब x==5 सत्य=1 है। आउटपुट: 5 1.
85
EN + हिं
GB What is the type of: sizeof expression?
IN अभिव्यक्ति का आकार क्या है?
A
int int यहाँ
B
unsigned int अहस्ताक्षरित int
C
size_t आकार_t
D
long लंबा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sizeof returns a value of type std::size_t, which is typically an unsigned integer type.
व्याख्या (हिन्दी) sizeof प्रकार std::size_t का मान लौटाता है, जो आम तौर पर एक अहस्ताक्षरित पूर्णांक प्रकार होता है।
86
EN + हिं
GB What is the output: int a=4,b=2; cout<<(a^=b,b^=a,a^=b)<<' '<
IN आउटपुट क्या है: int a=4,b=2; अदालत
A
2 2 4 2 2 4
B
4 2 4 4 2 4
C
Undefined अपरिभाषित
D
2 4 2 2 4 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) XOR swap: a^=b(a=6), b^=a(b=4), a^=b(a=2). Final: a=2, b=4. Comma returns last: a=2.
व्याख्या (हिन्दी) XOR स्वैप: a^=b(a=6), b^=a(b=4), a^=b(a=2)। अंतिम: a=2, b=4. अंत में अल्पविराम आता है: a=2.
87
EN + हिं
GB What is the output: cout << (1 << 0) << ' ' << (1 << 1) << ' ' << (1 << 4);
IN आउटपुट क्या है: cout
A
1 2 16 1 2 16
B
0 1 4 0 1 4
C
1 2 8 1 2 8
D
1 4 16 1 4 16
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1<<0=1, 1<<1=2, 1<<4=16.
व्याख्या (हिन्दी) 1
88
EN + हिं
GB What is the output: bool a=true,b=false; cout<<(a&&b)<<(a||b)<<(!a);
IN आउटपुट क्या है: bool a=true,b=false; अदालत
A
010 010
B
011 011
C
110 110
D
101 101
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a&&b=false=0, a||b=true=1, !a=false=0. Output: 010.
व्याख्या (हिन्दी) a&&b=false=0, a||b=true=1, !a=false=0. आउटपुट: 010.
89
EN + हिं
GB What does the :: operator do when used without a left-hand side?
IN बायीं ओर के बिना उपयोग किये जाने पर :: ऑपरेटर क्या करता है?
A
Accesses global namespace वैश्विक नामस्थान तक पहुँचता है
B
Causes compile error संकलन त्रुटि का कारण बनता है
C
Accesses current class वर्तमान कक्षा तक पहुँचता है
D
Accesses parent namespace पैरेंट नेमस्पेस तक पहुँचता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ::name accesses name in the global namespace, even if a local/class scope shadow exists.
व्याख्या (हिन्दी) ::नाम वैश्विक नामस्थान में नाम तक पहुंचता है, भले ही स्थानीय/वर्ग स्कोप छाया मौजूद हो।
90
EN + हिं
GB What is the output: int x=5; cout<
IN आउटपुट क्या है: int x=5; अदालत
A
556 556
B
566 566
C
Undefined behavior अपरिभाषित व्यवहार
D
555 555
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Pre-C++17, evaluating x, x++, and x in the same expression without sequencing is undefined behavior.
व्याख्या (हिन्दी) प्री-सी++17, अनुक्रमण के बिना एक ही अभिव्यक्ति में x, x++ और x का मूल्यांकन करना अपरिभाषित व्यवहार है।
76–90 of 1915