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
496
EN + हिं
GB What is 'memory order' in atomics?
IN परमाणु विज्ञान में 'मेमोरी ऑर्डर' क्या है?
A
Specifies synchronization strength of atomic operation परमाणु संचालन की तुल्यकालन शक्ति निर्दिष्ट करता है
B
Cache line order कैश लाइन ऑर्डर
C
Instruction ordering अनुदेश आदेश
D
Thread priority थ्रेड प्राथमिकता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Memory orders (relaxed, acquire, release, seq_cst) control visibility of memory operations across threads.
व्याख्या (हिन्दी) मेमोरी ऑर्डर (आराम, अधिग्रहण, रिलीज, seq_cst) थ्रेड्स में मेमोरी ऑपरेशंस की दृश्यता को नियंत्रित करते हैं।
497
EN + हिं
GB What is the output: int x=5; cout<<(x+0.0==5.0);
IN आउटपुट क्या है: int x=5; अदालत
A
1 1
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 converts to 5.0 exactly; 5.0==5.0=true=1. Output: 1.
व्याख्या (हिन्दी) 5 बिल्कुल 5.0 में परिवर्तित हो जाता है; 5.0==5.0=सत्य=1. आउटपुट: 1.
498
EN + हिं
GB What is 'std::bit_cast' in C++20?
IN C++20 में 'std::bit_cast' क्या है?
A
Reinterprets bits of one type as another safely एक प्रकार के बिट्स को दूसरे प्रकार के बिट्स के रूप में सुरक्षित रूप से पुनर्व्याख्यायित करता है
B
Same as reinterpret_cast पुनर्व्याख्या_कास्ट के समान
C
Runtime cast रनटाइम कास्ट
D
A union hack एक यूनियन हैक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::bit_cast(v) reinterprets the bit representation; safe type punning alternative to memcpy.
व्याख्या (हिन्दी) std::bit_cast(v) बिट प्रतिनिधित्व की पुनर्व्याख्या करता है; मेम्सीपीई का सुरक्षित प्रकार का पनिंग विकल्प।
499
EN + हिं
GB What is the output: int x=255; cout<<(x&0xF)<<((x>>4)&0xF);
IN आउटपुट क्या है: int x=255; अदालत
A
1515 1515
B
ff सीमांत बल
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0xFF&0xF=15, (0xFF>>4)&0xF=15. Output: 1515.
व्याख्या (हिन्दी) 0xFF&0xF=15, (0xFF>>4)&0xF=15. आउटपुट: 1515.
500
EN + हिं
GB What is 'std::span' zero-overhead guarantee?
IN 'std::span' शून्य-ओवरहेड गारंटी क्या है?
A
Non-owning view adds no allocation overhead गैर-स्वामित्व वाला दृश्य कोई आवंटन ओवरहेड नहीं जोड़ता है
B
Faster than vector वेक्टर से भी तेज़
C
Compile-time size संकलन-समय का आकार
D
Thread-safe सूत की अलमारी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::span stores only pointer+size; no heap allocation; same performance as raw pointer+size pair.
व्याख्या (हिन्दी) std::span केवल पॉइंटर+आकार को संग्रहीत करता है; कोई ढेर आवंटन नहीं; कच्चे सूचक+आकार जोड़ी के समान प्रदर्शन।
501
EN + हिं
GB What is the output: int x=5; cout<<(x^x^x);
IN आउटपुट क्या है: int x=5; अदालत
A
5 5
C
10 10
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x^x=0, 0^x=x=5. Output: 5.
व्याख्या (हिन्दी) x^x=0, 0^x=x=5. आउटपुट: 5.
502
EN + हिं
GB What is 'std::expected' in C++23?
IN C++23 में 'std::expected' क्या है?
A
Return type holding value or error without exceptions बिना किसी अपवाद के रिटर्न प्रकार होल्डिंग मान या त्रुटि
B
A variant type एक भिन्न प्रकार
C
An optional type एक वैकल्पिक प्रकार
D
An exception wrapper एक अपवाद आवरण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::expected holds either T (success) or E (error); alternative to exceptions for error handling.
व्याख्या (हिन्दी) std::expected या तो T (सफलता) या E (त्रुटि) रखता है; त्रुटि प्रबंधन के लिए अपवादों का विकल्प।
503
EN + हिं
GB What is the output: int x=0; cout<<(x||1)<<(x&&1)<<(!x);
IN आउटपुट क्या है: int x=0; अदालत
A
101 101
B
010 010
C
100 100
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0||1=1, 0&&1=0, !0=1. Output: 101.
व्याख्या (हिन्दी) 0||1=1, 0&&1=0, !0=1. आउटपुट: 101.
504
EN + हिं
GB What is 'CTAD' (Class Template Argument Deduction)?
IN 'सीटीएडी' (क्लास टेम्पलेट आर्गुमेंट डिडक्शन) क्या है?
A
Compiler deduces template args from constructor call (C++17) कंपाइलर कंस्ट्रक्टर कॉल से टेम्पलेट आर्ग्स निकालता है (C++17)
B
Concept-based deduction संकल्पना-आधारित कटौती
C
Runtime type deduction रनटाइम प्रकार की कटौती
D
Template specialization टेम्पलेट विशेषज्ञता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) CTAD: vector v={1,2,3}; deduces vector from initializer list in C++17.
व्याख्या (हिन्दी) CTAD: वेक्टर v={1,2,3}; C++17 में इनिशियलाइज़र सूची से वेक्टर निकालता है।
505
EN + हिं
GB What is the output: cout<<(sizeof(int)==sizeof(int*));
IN आउटपुट क्या है: cout
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 64-bit: sizeof(int)=4, sizeof(int*)=8. 4==8=false=0. Output: 0.
व्याख्या (हिन्दी) 64-बिट: साइज़ऑफ़(int)=4, साइज़ऑफ़(int*)=8। 4==8=असत्य=0. आउटपुट: 0.
506
EN + हिं
GB What is 'std::ranges' (C++20)?
IN 'std::ranges' (C++20) क्या है?
A
Range-based algorithms operating directly on containers रेंज-आधारित एल्गोरिदम सीधे कंटेनरों पर काम करते हैं
B
A container type एक कंटेनर प्रकार
C
Iterator wrappers इटरेटर रैपर
D
Copy of STL एसटीएल की प्रति
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::ranges algorithms accept ranges directly: std::ranges::sort(v) instead of sort(v.begin(),v.end()).
व्याख्या (हिन्दी) std::ranges एल्गोरिदम सीधे श्रेणियां स्वीकार करते हैं: sort(v.begin(),v.end() के बजाय std::ranges::sort(v)।
507
EN + हिं
GB What is the output: int x=15; for(;x;x&=x-1) cout<<'1';
IN आउटपुट क्या है: int x=15; for(;x;x&=x-1) cout
A
4 4
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x&=x-1 clears lowest set bit. 15=1111: 4 bits. Prints '1' four times: 1111. Output: 1111.
व्याख्या (हिन्दी) x&=x-1 न्यूनतम सेट बिट को साफ़ करता है। 15=1111: 4 बिट्स। '1' चार बार प्रिंट करता है: 1111. आउटपुट: 1111।
508
EN + हिं
GB What is 'std::format' in C++20?
IN C++20 में 'std::format' क्या है?
A
Type-safe string formatting like Python's f-strings पायथन की एफ-स्ट्रिंग्स की तरह टाइप-सुरक्षित स्ट्रिंग फ़ॉर्मेटिंग
B
A printf replacement एक प्रिंटफ़ प्रतिस्थापन
C
Only for numbers केवल संख्याओं के लिए
D
A regex function एक रेगेक्स फ़ंक्शन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::format("{} + {} = {}", 1, 2, 3) returns "1 + 2 = 3" — type-safe and extensible.
व्याख्या (हिन्दी) std::format("{} + {} = {}", 1, 2, 3) रिटर्न "1 + 2 = 3" - टाइप-सुरक्षित और एक्स्टेंसिबल।
509
EN + हिं
GB What is the output: int x=8; cout<<(x>0?x:x*-1);
IN आउटपुट क्या है: int x=8; अदालत
A
8 8
B
-8 -8
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x>0 true; returns x=8. Output: 8.
व्याख्या (हिन्दी) x>0 सत्य; x=8 लौटाता है। आउटपुट: 8.
510
EN + हिं
GB What is 'std::jthread' in C++20?
IN C++20 में 'std::jthread' क्या है?
A
Auto-joining thread with stop token support स्टॉप टोकन समर्थन के साथ स्वत: जुड़ने वाला धागा
B
Faster than std::thread एसटीडी::थ्रेड से तेज़
C
Same as std::thread एसटीडी::थ्रेड के समान
D
A coroutine thread एक कोरटाइन धागा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::jthread automatically joins on destruction and supports cooperative cancellation via stop_token.
व्याख्या (हिन्दी) std::jthread स्वचालित रूप से विनाश पर जुड़ जाता है और stop_token के माध्यम से सहकारी रद्दीकरण का समर्थन करता है।
496–510 of 1915