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
61
EN + हिं
GB What is 'attribute [[nodiscard]]'?
IN 'विशेषता [[नोडिस्कार्ड]]' क्या है?
A
Warns if return value is discarded अगर रिटर्न वैल्यू खारिज कर दिया जाए तो चेतावनी देता है
B
Makes function constexpr फ़ंक्शन कॉन्स्टेक्सपीआर बनाता है
C
Prevents inlining इनलाइनिंग को रोकता है
D
Marks deprecated function अस्वीकृत फ़ंक्शन को चिह्नित करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) [[nodiscard]] causes compiler warning if caller ignores return value; useful for error codes.
व्याख्या (हिन्दी) [[नोडिस्कार्ड]] यदि कॉलर रिटर्न वैल्यू को अनदेखा करता है तो कंपाइलर चेतावनी का कारण बनता है; त्रुटि कोड के लिए उपयोगी.
62
EN + हिं
GB What is the output: int x=3; cout<<(x<<1|1);
IN आउटपुट क्या है: int x=3; अदालत
A
7 7
B
6 6
C
3 3
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3<<1=6=110. 110|001=111=7. Output: 7.
व्याख्या (हिन्दी) 3
63
EN + हिं
GB What is 'likely' and 'unlikely' attributes in C++20?
IN C++20 में 'संभावित' और 'असंभावित' विशेषताएँ क्या हैं?
A
Hints to compiler about branch probability शाखा संभाव्यता के बारे में संकलक को संकेत
B
Forces branch elimination बल शाखा उन्मूलन
C
Runtime branch prediction रनटाइम शाखा भविष्यवाणी
D
Constexpr branches कॉन्स्टेक्सपीआर शाखाएँ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) [[likely]]/[[unlikely]] on if/switch branches hint branch predictor; may improve performance.
व्याख्या (हिन्दी) [[संभावना]]/[[संभावना नहीं]] अगर/स्विच शाखाएं संकेत शाखा भविष्यवक्ता पर; प्रदर्शन में सुधार हो सकता है.
64
EN + हिं
GB What is the output: auto x=42u; cout<
IN आउटपुट क्या है: ऑटो x=42u; अदालत
A
4 4
B
8 8
C
2 2
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42u is unsigned int; sizeof=4. Output: 4.
व्याख्या (हिन्दी) 42u अहस्ताक्षरित int है; आकार=4. आउटपुट: 4.
65
EN + हिं
GB What is 'ODR-use'?
IN 'ओडीआर-उपयोग' क्या है?
A
Using a variable/function in a way requiring its definition किसी वेरिएबल/फ़ंक्शन का इस प्रकार उपयोग करना कि उसकी परिभाषा आवश्यक हो
B
Object definition rule वस्तु परिभाषा नियम
C
Overload definition requirement अधिभार परिभाषा आवश्यकता
D
Override dispatch rule प्रेषण नियम को ओवरराइड करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ODR-use: if you take address of or bind reference to an entity, it must have exactly one definition.
व्याख्या (हिन्दी) ओडीआर-उपयोग: यदि आप किसी इकाई का पता लेते हैं या उसका संदर्भ लेते हैं, तो इसकी बिल्कुल एक परिभाषा होनी चाहिए।
66
EN + हिं
GB What is the output: int x=10; cout<<(x-=3)<
IN आउटपुट क्या है: int x=10; अदालत
A
77 77
B
710 710
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x-=3 sets x=7, returns 7. C++17 left-to-right: 7 then 7. Output: 77.
व्याख्या (हिन्दी) x-=3 सेट x=7, रिटर्न 7. C++17 बाएँ से दाएँ: 7 फिर 7. आउटपुट: 77.
67
EN + हिं
GB What is 'std::source_location' in C++20?
IN C++20 में 'std::source_location' क्या है?
A
Provides file, line, function info at compile time संकलन समय पर फ़ाइल, लाइन, फ़ंक्शन जानकारी प्रदान करता है
B
Runtime stack trace रनटाइम स्टैक ट्रेस
C
Debugger integration डिबगर एकीकरण
D
Exception location अपवाद स्थान
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::source_location::current() captures file name, line number, and function name at compile time.
व्याख्या (हिन्दी) std::source_location::current() संकलन समय पर फ़ाइल नाम, लाइन नंबर और फ़ंक्शन नाम कैप्चर करता है।
68
EN + हिं
GB What is the output: int x=5; int y=x; x=x^y; y=x^y; x=x^y; cout<
IN आउटपुट क्या है: int x=5; int y=x; x=x^y; y=x^y; x=x^y; अदालत
A
05 05
B
55 55
C
50 50
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=y=5. x^=y=0; y^=x=5; x^=y=5. Swap of equal values: x=5,y=5. Output: 55.
व्याख्या (हिन्दी) एक्स=वाई=5. x^=y=0; y^=x=5; x^=y=5. समान मानों की अदला-बदली: x=5,y=5. आउटपुट: 55.
69
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) थ्रेड्स में मेमोरी ऑपरेशंस की दृश्यता को नियंत्रित करते हैं।
70
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.
71
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) बिट प्रतिनिधित्व की पुनर्व्याख्या करता है; मेम्सीपीई का सुरक्षित प्रकार का पनिंग विकल्प।
72
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.
73
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 केवल पॉइंटर+आकार को संग्रहीत करता है; कोई ढेर आवंटन नहीं; कच्चे सूचक+आकार जोड़ी के समान प्रदर्शन।
74
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.
75
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 (त्रुटि) रखता है; त्रुटि प्रबंधन के लिए अपवादों का विकल्प।
61–75 of 187