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
481
EN + हिं
GB What is the output: int x=6; cout<<(x&-x)<<' '<<(x/( x&-x));
IN आउटपुट क्या है: int x=6; अदालत
A
2 3 2 3
B
1 6 1 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 6&-6=6&...11111010=2. 6/2=3. Output: 2 3.
व्याख्या (हिन्दी) 6&-6=6&...11111010=2. 6/2=3. आउटपुट: 2 3.
482
EN + हिं
GB What is 'fold expression' with &&?
IN && के साथ 'फोल्ड एक्सप्रेशन' क्या है?
A
(args && ...) — true if all args are true (args && ...) - यदि सभी तर्क सत्य हैं तो सत्य है
B
(args || ...) equivalent (तर्क || ...) समतुल्य
C
Runtime only केवल रनटाइम
D
Template only केवल टेम्पलेट
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (args && ...) is a fold over &&; equivalent to arg1 && arg2 && ... argN.
व्याख्या (हिन्दी) (तर्क && ...) एक गुना अधिक है &&; arg1 && arg2 && ... argN के समतुल्य।
483
EN + हिं
GB What is the output: int x=0b11001100; cout<<__builtin_popcount(x);
IN आउटपुट क्या है: int x=0b11001100; अदालत
A
4 4
B
8 8
C
6 6
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Bits set in 11001100: 4. Output: 4.
व्याख्या (हिन्दी) बिट्स 11001100 में सेट: 4. आउटपुट: 4.
484
EN + हिं
GB What is 'zero initialization'?
IN 'शून्य आरंभीकरण' क्या है?
A
Setting memory to zero: 0 for scalars, null for pointers मेमोरी को शून्य पर सेट करना: स्केलर के लिए 0, पॉइंटर्स के लिए शून्य
B
Calling default constructor डिफ़ॉल्ट कंस्ट्रक्टर को कॉल करना
C
Stack clearing ढेर साफ़ करना
D
Register zeroing शून्यीकरण रजिस्टर करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Zero initialization sets all bytes to 0; happens for static variables and explicitly with {}.
व्याख्या (हिन्दी) शून्य आरंभीकरण सभी बाइट्स को 0 पर सेट करता है; स्थिर चर के लिए और स्पष्ट रूप से {} के साथ होता है।
485
EN + हिं
GB What is the output: cout<<__func__;
IN आउटपुट क्या है: cout
A
main मुख्य
B
__func__ __func__
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) __func__ is predefined string literal containing current function name. Output: main.
व्याख्या (हिन्दी) __func__ पूर्वनिर्धारित स्ट्रिंग शाब्दिक है जिसमें वर्तमान फ़ंक्शन नाम शामिल है। आउटपुट: मुख्य.
486
EN + हिं
GB What is 'string interning' concept?
IN 'स्ट्रिंग इंटर्निंग' अवधारणा क्या है?
A
Reusing same string object for equal strings समान स्ट्रिंग के लिए समान स्ट्रिंग ऑब्जेक्ट का पुन: उपयोग करना
B
Storing strings in array सरणी में स्ट्रिंग संग्रहीत करना
C
String pooling at link time लिंक समय पर स्ट्रिंग पूलिंग
D
Const string optimization कॉन्स्ट स्ट्रिंग अनुकूलन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) String interning ensures equal string literals share the same memory; implementation-defined in C++.
व्याख्या (हिन्दी) स्ट्रिंग इंटर्निंग सुनिश्चित करती है कि समान स्ट्रिंग अक्षर समान मेमोरी साझा करें; C++ में कार्यान्वयन-परिभाषित।
487
EN + हिं
GB What is the output: int x=10; cout<<(x&~(x-1));
IN आउटपुट क्या है: int x=10; अदालत
A
2 2
B
10 10
C
8 8
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10=1010, 9=1001, ~9=...0110. 1010&0110=0010=2. Output: 2.
व्याख्या (हिन्दी) 10=1010, 9=1001, ~9=...0110। 1010&0110=0010=2. आउटपुट: 2.
488
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.
व्याख्या (हिन्दी) [[नोडिस्कार्ड]] यदि कॉलर रिटर्न वैल्यू को अनदेखा करता है तो कंपाइलर चेतावनी का कारण बनता है; त्रुटि कोड के लिए उपयोगी.
489
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
490
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.
व्याख्या (हिन्दी) [[संभावना]]/[[संभावना नहीं]] अगर/स्विच शाखाएं संकेत शाखा भविष्यवक्ता पर; प्रदर्शन में सुधार हो सकता है.
491
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.
492
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.
व्याख्या (हिन्दी) ओडीआर-उपयोग: यदि आप किसी इकाई का पता लेते हैं या उसका संदर्भ लेते हैं, तो इसकी बिल्कुल एक परिभाषा होनी चाहिए।
493
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.
494
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() संकलन समय पर फ़ाइल नाम, लाइन नंबर और फ़ंक्शन नाम कैप्चर करता है।
495
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.
481–495 of 1915