OOP Using C++ — MCQ Practice

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

📚 187 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
187 questions
31
EN + हिं
GB What is the output: int x = -1; unsigned int y = x; cout << (y > 0);
IN आउटपुट क्या है: int x = -1; अहस्ताक्षरित int y = x; कोउट 0);
B
1 1
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) -1 converted to unsigned int becomes UINT_MAX (a large positive number), so y > 0 is true, output is 1.
व्याख्या (हिन्दी) -1 को अहस्ताक्षरित int में परिवर्तित करने पर UINT_MAX (एक बड़ी धनात्मक संख्या) बन जाती है, इसलिए y > 0 सत्य है, आउटपुट 1 है।
32
EN + हिं
GB What is a 'sequence point' in C++?
IN C++ में 'अनुक्रम बिंदु' क्या है?
A
A point where all side effects are complete एक ऐसा बिंदु जहां सभी दुष्प्रभाव पूर्ण हो जाते हैं
B
A semicolon in code कोड में एक अर्धविराम
C
A function call boundary एक फ़ंक्शन कॉल सीमा
D
A memory barrier एक स्मृति बाधा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A sequence point ensures all side effects of previous evaluations are complete before the next expression begins evaluation.
व्याख्या (हिन्दी) एक अनुक्रम बिंदु यह सुनिश्चित करता है कि अगली अभिव्यक्ति का मूल्यांकन शुरू होने से पहले पिछले मूल्यांकन के सभी दुष्प्रभाव पूरे हो जाएं।
33
EN + हिं
GB In C++, what does 'decltype(auto)' do?
IN C++ में, 'decltype(auto)' क्या करता है?
A
Deduces type like auto ऑटो जैसे प्रकार का अनुमान लगाता है
B
Deduces exact type including references संदर्भ सहित सटीक प्रकार का पता लगाता है
C
Only works with templates केवल टेम्प्लेट के साथ काम करता है
D
Equivalent to decltype डिक्ल्टाइप के समतुल्य
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) decltype(auto) deduces the type using decltype rules, preserving reference and cv-qualifiers, unlike plain auto which strips them.
व्याख्या (हिन्दी) decltype(auto) संदर्भ और cv-क्वालिफायर को संरक्षित करते हुए, decltype नियमों का उपयोग करके प्रकार का अनुमान लगाता है, सादे ऑटो के विपरीत जो उन्हें हटा देता है।
34
EN + हिं
GB What is the maximum value of a signed 32-bit integer?
IN हस्ताक्षरित 32-बिट पूर्णांक का अधिकतम मान क्या है?
A
2^32 - 1 2^32 - 1
B
2^31 2^31
C
2^31 - 1 2^31 - 1
D
2^32 2^32
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A signed 32-bit int stores values from -2^31 to 2^31-1, i.e., -2147483648 to 2147483647.
व्याख्या (हिन्दी) एक हस्ताक्षरित 32-बिट इंट -2^31 से 2^31-1 तक मान संग्रहीत करता है, अर्थात, -2147483648 से 2147483647 तक।
35
EN + हिं
GB What is the output: cout<<(1<<3)+(1<<2)+(1<<0);
IN आउटपुट क्या है: cout
A
13 13
B
8 8
C
14 14
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 8+4+1=13.
व्याख्या (हिन्दी) 8+4+1=13.
36
EN + हिं
GB What is 'alignment' in C++?
IN C++ में 'संरेखण' क्या है?
A
Memory address constraint for a type एक प्रकार के लिए मेमोरी एड्रेस बाधा
B
Cache line size कैश लाइन का आकार
C
Struct packing संरचना पैकिंग
D
Padding removal पैडिंग हटाना
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Alignment: CPU requires objects at addresses divisible by their alignment (e.g., int at 4-byte boundary).
व्याख्या (हिन्दी) संरेखण: सीपीयू को उनके संरेखण द्वारा विभाज्य पते पर वस्तुओं की आवश्यकता होती है (उदाहरण के लिए, 4-बाइट सीमा पर int)।
37
EN + हिं
GB What is the output: int x=5; cout<<(x>0)+(x>3)+(x>4)+(x>5);
IN आउटपुट क्या है: int x=5; cout3)+(x>4)+(x>5);
A
3 3
B
4 4
C
2 2
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+1+1+0=3. Output: 3.
व्याख्या (हिन्दी) 1+1+1+0=3. आउटपुट: 3.
38
EN + हिं
GB What does 'explicit' keyword prevent?
IN 'स्पष्ट' कीवर्ड क्या रोकता है?
A
Implicit single-argument constructor conversion अंतर्निहित एकल-तर्क कंस्ट्रक्टर रूपांतरण
B
Copy construction निर्माण की प्रतिलिपि बनाएँ
C
Virtual dispatch आभासी प्रेषण
D
Template instantiation टेम्पलेट इन्स्टेन्शियशन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) explicit prevents compiler using constructor for implicit type conversion.
व्याख्या (हिन्दी) स्पष्ट अंतर्निहित प्रकार के रूपांतरण के लिए कंस्ट्रक्टर का उपयोग करने वाले कंपाइलर को रोकता है।
39
EN + हिं
GB What is the output: int x=0xFF; cout<<(x>>4)&0xF;
IN आउटपुट क्या है: int x=0xFF; cout4)&0xF;
A
15 15
C
255 255
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0xFF>>4=0x0F=15. 15&15=15. Output: 15.
व्याख्या (हिन्दी) 0xFF>>4=0x0F=15. 15&15=15. आउटपुट: 15.
40
EN + हिं
GB What is 'std::byte' vs unsigned char?
IN 'एसटीडी::बाइट' बनाम अहस्ताक्षरित चार क्या है?
A
byte has no arithmetic; only bitwise ops; expresses intent बाइट का कोई अंकगणित नहीं है; केवल बिटवाइज़ ऑप्स; इरादा व्यक्त करता है
B
They are identical वे समान हैं
C
byte is larger बाइट बड़ा है
D
byte is signed बाइट हस्ताक्षरित है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::byte signals raw memory intent; no accidental arithmetic.
व्याख्या (हिन्दी) std::बाइट कच्चे मेमोरी इरादे का संकेत देता है; कोई आकस्मिक अंकगणित नहीं.
41
EN + हिं
GB What is the output: bool b; cout<
IN आउटपुट क्या है: बूल बी; अदालत
A
Undefined behavior अपरिभाषित व्यवहार
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Reading uninitialized bool is UB.
व्याख्या (हिन्दी) अप्रारंभीकृत बूल को पढ़ना यूबी है।
42
EN + हिं
GB What is 'structured binding' for pair?
IN जोड़ी के लिए 'संरचित बंधन' क्या है?
A
auto [first,second]=pair; decomposes into named vars ऑटो [प्रथम,दूसरा]=जोड़ी; नामित वर्नों में विघटित हो जाता है
B
Reference binding संदर्भ बाइंडिंग
C
C++20 only केवल सी++20
D
Template binding टेम्पलेट बाइंडिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17: auto [a,b]=make_pair(1,2); gives a=1, b=2.
व्याख्या (हिन्दी) सी++17: ऑटो [ए,बी]=मेक_पेयर(1,2); a=1, b=2 देता है।
43
EN + हिं
GB What is the output: int x=7; cout<<(x&(x+1));
IN आउटपुट क्या है: int x=7; अदालत
B
7 7
C
8 8
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7=0111, 8=1000. AND=0. Output: 0.
व्याख्या (हिन्दी) 7=0111, 8=1000. तथा=0. आउटपुट: 0.
44
EN + हिं
GB What is 'std::endl' vs '\\n'?
IN 'std::endl' बनाम '\\n' क्या है?
A
endl flushes buffer; \\n does not एंडल बफर को फ्लश करता है; \\nनहीं है
B
No difference कोई फर्क नहीं
C
\\n is slower \\n धीमा है
D
endl is deprecated एंडल को बहिष्कृत कर दिया गया है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::endl outputs newline AND flushes the stream; '\\n' only outputs newline — faster.
व्याख्या (हिन्दी) std::endl न्यूलाइन आउटपुट करता है और स्ट्रीम को फ्लश करता है; '\\n' केवल न्यूलाइन को आउटपुट करता है - तेज।
45
EN + हिं
GB What is the output: int x=10; while(x) {x>>=1;} cout<
IN आउटपुट क्या है: int x=10; जबकि(x) {x>>=1;} कोउट
B
1 1
C
10 10
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10->5->2->1->0. Loop exits. Output: 0.
व्याख्या (हिन्दी) 10->5->2->1->0. लूप बाहर निकलता है. आउटपुट: 0.
31–45 of 187