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

Question 61

EN + हिं
GB What is 'attribute [[nodiscard]]'?
IN 'विशेषता [[नोडिस्कार्ड]]' क्या है?
Warns if return value is discarded अगर रिटर्न वैल्यू खारिज कर दिया जाए तो चेतावनी देता है
Makes function constexpr फ़ंक्शन कॉन्स्टेक्सपीआर बनाता है
Prevents inlining इनलाइनिंग को रोकता है
Marks deprecated function अस्वीकृत फ़ंक्शन को चिह्नित करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) [[nodiscard]] causes compiler warning if caller ignores return value; useful for error codes.
व्याख्या (हिन्दी) [[नोडिस्कार्ड]] यदि कॉलर रिटर्न वैल्यू को अनदेखा करता है तो कंपाइलर चेतावनी का कारण बनता है; त्रुटि कोड के लिए उपयोगी.
🎯 Exam Perspective
OOP Using C++ ("Introduction to C++" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 62

EN + हिं
GB What is the output: int x=3; cout<<(x<<1|1);
IN आउटपुट क्या है: int x=3; अदालत
7 7
6 6
3 3
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3<<1=6=110. 110|001=111=7. Output: 7.
व्याख्या (हिन्दी) 3
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Introduction to C++" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 63

EN + हिं
GB What is 'likely' and 'unlikely' attributes in C++20?
IN C++20 में 'संभावित' और 'असंभावित' विशेषताएँ क्या हैं?
Hints to compiler about branch probability शाखा संभाव्यता के बारे में संकलक को संकेत
Forces branch elimination बल शाखा उन्मूलन
Runtime branch prediction रनटाइम शाखा भविष्यवाणी
Constexpr branches कॉन्स्टेक्सपीआर शाखाएँ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) [[likely]]/[[unlikely]] on if/switch branches hint branch predictor; may improve performance.
व्याख्या (हिन्दी) [[संभावना]]/[[संभावना नहीं]] अगर/स्विच शाखाएं संकेत शाखा भविष्यवक्ता पर; प्रदर्शन में सुधार हो सकता है.
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Introduction to C++" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 64

EN + हिं
GB What is the output: auto x=42u; cout<
IN आउटपुट क्या है: ऑटो x=42u; अदालत
4 4
8 8
2 2
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42u is unsigned int; sizeof=4. Output: 4.
व्याख्या (हिन्दी) 42u अहस्ताक्षरित int है; आकार=4. आउटपुट: 4.
🎯 Exam Perspective
OOP Using C++ ("Introduction to C++" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 65

EN + हिं
GB What is 'ODR-use'?
IN 'ओडीआर-उपयोग' क्या है?
Using a variable/function in a way requiring its definition किसी वेरिएबल/फ़ंक्शन का इस प्रकार उपयोग करना कि उसकी परिभाषा आवश्यक हो
Object definition rule वस्तु परिभाषा नियम
Overload definition requirement अधिभार परिभाषा आवश्यकता
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.
व्याख्या (हिन्दी) ओडीआर-उपयोग: यदि आप किसी इकाई का पता लेते हैं या उसका संदर्भ लेते हैं, तो इसकी बिल्कुल एक परिभाषा होनी चाहिए।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Introduction to C++" sub-topic) category का है, और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 66

EN + हिं
GB What is the output: int x=10; cout<<(x-=3)<
IN आउटपुट क्या है: int x=10; अदालत
77 77
710 710
Undefined अपरिभाषित
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.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Introduction to C++" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 67

EN + हिं
GB What is 'std::source_location' in C++20?
IN C++20 में 'std::source_location' क्या है?
Provides file, line, function info at compile time संकलन समय पर फ़ाइल, लाइन, फ़ंक्शन जानकारी प्रदान करता है
Runtime stack trace रनटाइम स्टैक ट्रेस
Debugger integration डिबगर एकीकरण
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() संकलन समय पर फ़ाइल नाम, लाइन नंबर और फ़ंक्शन नाम कैप्चर करता है।
🎯 Exam Perspective
OOP Using C++ ("Introduction to C++" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 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; अदालत
05 05
55 55
50 50
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.
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में OOP Using C++ ("Introduction to C++" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 69

EN + हिं
GB What is 'memory order' in atomics?
IN परमाणु विज्ञान में 'मेमोरी ऑर्डर' क्या है?
Specifies synchronization strength of atomic operation परमाणु संचालन की तुल्यकालन शक्ति निर्दिष्ट करता है
Cache line order कैश लाइन ऑर्डर
Instruction ordering अनुदेश आदेश
Thread priority थ्रेड प्राथमिकता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Memory orders (relaxed, acquire, release, seq_cst) control visibility of memory operations across threads.
व्याख्या (हिन्दी) मेमोरी ऑर्डर (आराम, अधिग्रहण, रिलीज, seq_cst) थ्रेड्स में मेमोरी ऑपरेशंस की दृश्यता को नियंत्रित करते हैं।
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Introduction to C++" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 70

EN + हिं
GB What is the output: int x=5; cout<<(x+0.0==5.0);
IN आउटपुट क्या है: int x=5; अदालत
1 1
Undefined अपरिभाषित
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.
🎯 Exam Perspective
OOP Using C++ ("Introduction to C++" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 71

EN + हिं
GB What is 'std::bit_cast' in C++20?
IN C++20 में 'std::bit_cast' क्या है?
Reinterprets bits of one type as another safely एक प्रकार के बिट्स को दूसरे प्रकार के बिट्स के रूप में सुरक्षित रूप से पुनर्व्याख्यायित करता है
Same as reinterpret_cast पुनर्व्याख्या_कास्ट के समान
Runtime cast रनटाइम कास्ट
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) बिट प्रतिनिधित्व की पुनर्व्याख्या करता है; मेम्सीपीई का सुरक्षित प्रकार का पनिंग विकल्प।
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Introduction to C++" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 72

EN + हिं
GB What is the output: int x=255; cout<<(x&0xF)<<((x>>4)&0xF);
IN आउटपुट क्या है: int x=255; अदालत
1515 1515
ff सीमांत बल
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0xFF&0xF=15, (0xFF>>4)&0xF=15. Output: 1515.
व्याख्या (हिन्दी) 0xFF&0xF=15, (0xFF>>4)&0xF=15. आउटपुट: 1515.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ ("Introduction to C++" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 73

EN + हिं
GB What is 'std::span' zero-overhead guarantee?
IN 'std::span' शून्य-ओवरहेड गारंटी क्या है?
Non-owning view adds no allocation overhead गैर-स्वामित्व वाला दृश्य कोई आवंटन ओवरहेड नहीं जोड़ता है
Faster than vector वेक्टर से भी तेज़
Compile-time size संकलन-समय का आकार
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 केवल पॉइंटर+आकार को संग्रहीत करता है; कोई ढेर आवंटन नहीं; कच्चे सूचक+आकार जोड़ी के समान प्रदर्शन।
🎯 Exam Perspective
OOP Using C++ ("Introduction to C++" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 74

EN + हिं
GB What is the output: int x=5; cout<<(x^x^x);
IN आउटपुट क्या है: int x=5; अदालत
5 5
10 10
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x^x=0, 0^x=x=5. Output: 5.
व्याख्या (हिन्दी) x^x=0, 0^x=x=5. आउटपुट: 5.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में OOP Using C++ ("Introduction to C++" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 75

EN + हिं
GB What is 'std::expected' in C++23?
IN C++23 में 'std::expected' क्या है?
Return type holding value or error without exceptions बिना किसी अपवाद के रिटर्न प्रकार होल्डिंग मान या त्रुटि
A variant type एक भिन्न प्रकार
An optional type एक वैकल्पिक प्रकार
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 (त्रुटि) रखता है; त्रुटि प्रबंधन के लिए अपवादों का विकल्प।
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो OOP Using C++ ("Introduction to C++" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।