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
76
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.
77
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 में इनिशियलाइज़र सूची से वेक्टर निकालता है।
78
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.
79
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)।
80
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।
81
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" - टाइप-सुरक्षित और एक्स्टेंसिबल।
82
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.
83
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 के माध्यम से सहकारी रद्दीकरण का समर्थन करता है।
84
EN + हिं
GB What is the output: int x=5; cout<<(x*x-1)/(x+1);
IN आउटपुट क्या है: int x=5; अदालत
A
4 4
B
5 5
C
6 6
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (25-1)/(6)=24/6=4. Output: 4.
व्याख्या (हिन्दी) (25-1)/(6)=24/6=4. आउटपुट: 4.
85
EN + हिं
GB What is 'std::latch' in C++20?
IN C++20 में 'std::latch' क्या है?
A
Single-use countdown synchronization primitive एकल-उपयोग उलटी गिनती तुल्यकालन आदिम
B
Mutex wrapper म्यूटेक्स आवरण
C
Semaphore सिकंदरा
D
Barrier रुकावट
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::latch counts down to zero; threads wait until count reaches zero; not reusable.
व्याख्या (हिन्दी) std::latch की गिनती शून्य तक; गिनती शून्य तक पहुंचने तक धागे प्रतीक्षा करते हैं; पुन: प्रयोज्य नहीं.
86
EN + हिं
GB What is the output: auto x=2; auto y=3; cout<
IN आउटपुट क्या है: ऑटो x=2; ऑटो y=3; अदालत
A
3 3
B
3.33 3.33
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) decltype(x+y) is int. int(10)/3=3. Output: 3.
व्याख्या (हिन्दी) decltype(x+y) int है। int(10)/3=3. आउटपुट: 3.
87
EN + हिं
GB What is 'std::barrier' in C++20?
IN C++20 में 'std::barrier' क्या है?
A
Reusable synchronization point where all threads must arrive पुन: प्रयोज्य सिंक्रनाइज़ेशन बिंदु जहां सभी थ्रेड्स अवश्य पहुंचने चाहिए
B
A mutex एक म्यूटेक्स
C
A semaphore एक सेमाफोर
D
A latch एक कुंडी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::barrier is a reusable barrier; threads block until all arrive, then completion function runs.
व्याख्या (हिन्दी) std::बैरियर एक पुन: प्रयोज्य बैरियर है; सभी थ्रेड्स आने तक ब्लॉक रहते हैं, फिर कंप्लीशन फ़ंक्शन चलता है।
88
EN + हिं
GB What is the output: int x=100; cout<<(x&(-x)==x);
IN आउटपुट क्या है: int x=100; अदालत
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 100&(-100)=4≠100. So 4==100=false=0. Output: 0.
व्याख्या (हिन्दी) 100&(-100)=4≠100. तो 4==100=असत्य=0. आउटपुट: 0.
89
EN + हिं
GB What is 'std::counting_semaphore' in C++20?
IN C++20 में 'std::counting_semafore' क्या है?
A
Semaphore with configurable count for resource limiting संसाधन सीमित करने के लिए विन्यास योग्य गणना के साथ सेमाफोर
B
A mutex variant एक म्यूटेक्स वैरिएंट
C
A thread pool एक थ्रेड पूल
D
A barrier variant एक बाधा संस्करण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::counting_semaphore allows up to N concurrent acquires; useful for resource pools.
व्याख्या (हिन्दी) std::counting_semafore एन समवर्ती अधिग्रहण तक की अनुमति देता है; संसाधन पूल के लिए उपयोगी.
90
EN + हिं
GB What is the output: int x=7; cout<<(x|(x-1));
IN आउटपुट क्या है: int x=7; अदालत
A
7 7
B
6 6
C
15 15
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7=111, 6=110. 111|110=111=7. Output: 7.
व्याख्या (हिन्दी) 7=111, 6=110. 111|110=111=7. आउटपुट: 7.
76–90 of 187