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
466
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.
467
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::बाइट कच्चे मेमोरी इरादे का संकेत देता है; कोई आकस्मिक अंकगणित नहीं.
468
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.
व्याख्या (हिन्दी) अप्रारंभीकृत बूल को पढ़ना यूबी है।
469
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 देता है।
470
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.
471
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' केवल न्यूलाइन को आउटपुट करता है - तेज।
472
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.
473
EN + हिं
GB What is 'extern' keyword for variables?
IN वेरिएबल के लिए 'बाहरी' कीवर्ड क्या है?
A
Declares variable defined elsewhere (no storage allocated) अन्यत्र परिभाषित चर की घोषणा करता है (कोई संग्रहण आवंटित नहीं)
B
Defines global variable वैश्विक चर को परिभाषित करता है
C
Makes variable const परिवर्तनीय स्थिरांक बनाता है
D
Hides variable परिवर्तनशील छुपाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) extern int x; declares x without defining; linker finds definition in another TU.
व्याख्या (हिन्दी) बाहरी पूर्णांक x; परिभाषित किए बिना x घोषित करता है; लिंकर को किसी अन्य TU में परिभाषा मिलती है।
474
EN + हिं
GB What is the output: int x=5; cout<<(x|(x<<1));
IN आउटपुट क्या है: int x=5; अदालत
A
15 15
B
5 5
C
10 10
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5=101, 5<<1=1010. 101|1010=1111=15. Output: 15.
व्याख्या (हिन्दी) 5=101, 5
475
EN + हिं
GB What is 'address sanitizer'?
IN 'एड्रेस सैनिटाइजर' क्या है?
A
Runtime tool detecting memory errors (OOB, use-after-free) मेमोरी त्रुटियों का पता लगाने वाला रनटाइम टूल (ओओबी, उपयोग-बाद-मुक्त)
B
A debugger एक डिबगर
C
A profiler एक प्रोफाइलर
D
A linter एक लिंटर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) AddressSanitizer (ASan) instruments code to detect buffer overflows, use-after-free, etc. at runtime.
व्याख्या (हिन्दी) रनटाइम पर बफर ओवरफ्लो, उपयोग-बाद-मुक्त आदि का पता लगाने के लिए एड्रेससैनिटाइज़र (एएसएएन) उपकरण कोड।
476
EN + हिं
GB What is the output: for(int i=1;i<6;i++) cout<<(i*i-1)/(i+1)+1;
IN आउटपुट क्या है: for(int i=1;i
A
12345 12345
B
23456 23456
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (i^2-1)/(i+1)=(i-1)(i+1)/(i+1)=i-1. i-1+1=i. Prints 1,2,3,4,5. Output: 12345.
व्याख्या (हिन्दी) (i^2-1)/(i+1)=(i-1)(i+1)/(i+1)=i-1. मैं-1+1=मैं. 1,2,3,4,5 प्रिंट करता है। आउटपुट: 12345.
477
EN + हिं
GB What is the output: int x=0; auto f=[&]{x=42;}; f(); cout<
IN आउटपुट क्या है: int x=0; ऑटो f=[&]{x=42;}; एफ(); अदालत
A
42 42
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() modifies x via ref capture. x=42. Output: 42.
व्याख्या (हिन्दी) f() रेफ कैप्चर के माध्यम से x को संशोधित करता है। एक्स=42. आउटपुट: 42.
478
EN + हिं
GB What is 'std::as_const'?
IN 'std::as_const' क्या है?
A
Returns const reference to argument तर्क का स्थिर संदर्भ लौटाता है
B
Casts to const pointer कॉन्स्ट पॉइंटर पर कास्ट करता है
C
Removes const स्थिरांक हटाता है
D
Makes constexpr constexpr बनाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::as_const(x) returns const T& to x; useful for calling const overloads explicitly.
व्याख्या (हिन्दी) std::as_const(x) स्थिरांक T& को x पर लौटाता है; कॉन्स्ट ओवरलोड को स्पष्ट रूप से कॉल करने के लिए उपयोगी।
479
EN + हिं
GB What is the output: int x=5; cout<<(-(-x));
IN आउटपुट क्या है: int x=5; अदालत
A
5 5
B
-5 -5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (1, 6, 71, 1, 4, 'What is 'undefined behavior sanitizer'?
व्याख्या (हिन्दी) (1, 6, 71, 1, 4, 'अपरिभाषित व्यवहार सैनिटाइज़र' क्या है?
480
EN + हिं
GB What is 'undefined behavior sanitizer'?
IN 'अपरिभाषित व्यवहार सैनिटाइज़र' क्या है?
A
Runtime tool detecting UB (signed overflow, null deref, etc.) यूबी का पता लगाने वाला रनटाइम टूल (हस्ताक्षरित ओवरफ़्लो, नल डेरेफ़, आदि)
B
Same as ASan आसन के समान
C
A compiler flag एक संकलक ध्वज
D
A linker option एक लिंकर विकल्प
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) UBSan instruments code to detect undefined behavior at runtime with detailed diagnostics.
व्याख्या (हिन्दी) विस्तृत निदान के साथ रनटाइम पर अपरिभाषित व्यवहार का पता लगाने के लिए यूबीएसएन उपकरण कोड।
466–480 of 1915