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
541
EN + हिं
GB What is the output: int x=5; cout<<(x>0)*x+(x<0)*(-x);
IN आउटपुट क्या है: int x=5; अदालत
A
5 5
C
-5 -5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (1)*5+(0)*(-5)=5. Output: 5.
व्याख्या (हिन्दी) (1)*5+(0)*(-5)=5. आउटपुट: 5.
542
EN + हिं
GB What is 'NaN' in floating point?
IN फ्लोटिंग पॉइंट में 'NaN' क्या है?
A
Not a Number: result of undefined operations like 0.0/0.0 कोई संख्या नहीं: 0.0/0.0 जैसे अपरिभाषित परिचालनों का परिणाम
B
Negative infinity नकारात्मक अनन्तता
C
Very small number बहुत छोटी संख्या
D
Zero शून्य
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) NaN != NaN is always true; use isnan() to check.
व्याख्या (हिन्दी) NaN != NaN सदैव सत्य है; जांचने के लिए इसनान() का उपयोग करें।
543
EN + हिं
GB What is the output: double x=0.0/0.0; cout<<(x==x);
IN आउटपुट क्या है: डबल x=0.0/0.0; अदालत
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) NaN != NaN by IEEE 754. Output: 0.
व्याख्या (हिन्दी) NaN != NaN बाय आईईईई 754. आउटपुट: 0.
544
EN + हिं
GB What is 'consteval if' in C++23?
IN C++23 में 'consteval if' क्या है?
A
if consteval: true branch when in constant evaluation context यदि स्थिरता: निरंतर मूल्यांकन संदर्भ में सच्ची शाखा
B
Same as if constexpr कॉन्स्टेक्सपीआर के समान
C
Runtime check रनटाइम जांच
D
A concept संप्रत्यय
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) if consteval allows different code for compile-time vs runtime contexts within constexpr functions.
व्याख्या (हिन्दी) यदि कॉन्स्टेवल कॉन्स्टेक्सपीआर फ़ंक्शंस के भीतर संकलन-समय बनाम रनटाइम संदर्भों के लिए अलग-अलग कोड की अनुमति देता है।
545
EN + हिं
GB What is the output: int x=10; cout<<(x>>1)<<(x&1);
IN आउटपुट क्या है: int x=10; cout1)
A
50 50
B
51 51
C
10 10
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10>>1=5, 10&1=0. Output: 50.
व्याख्या (हिन्दी) 10>>1=5, 10&1=0. आउटपुट: 50.
546
EN + हिं
GB What is 'std::in_place_t'?
IN 'std::in_place_t' क्या है?
A
Tag type for in-place construction in optional/variant वैकल्पिक/संस्करण में इन-प्लेस निर्माण के लिए टैग प्रकार
B
A placement new variant एक प्लेसमेंट नया संस्करण
C
A lambda tag एक लैम्ब्डा टैग
D
A concept संप्रत्यय
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::in_place enables constructing contained value directly: optional(in_place, args...).
व्याख्या (हिन्दी) std::in_place सीधे निहित मूल्य का निर्माण करने में सक्षम बनाता है: वैकल्पिक (in_place, args...)।
547
EN + हिं
GB What is the output: int x=INT_MIN; cout<<(x<0);
IN आउटपुट क्या है: int x=INT_MIN; अदालत
A
1 1
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) INT_MIN is the most negative int; INT_MIN<0=true=1. Output: 1.
व्याख्या (हिन्दी) INT_MIN सबसे नकारात्मक int है; INT_MIN
548
EN + हिं
GB What is 'deduction guide for std::pair'?
IN 'एसटीडी::जोड़ी के लिए कटौती गाइड' क्या है?
A
pair(T,U)->pair<T,U> enables CTAD युग्म(T,U)->युग्म CTAD को सक्षम बनाता है
B
Manual template arg मैनुअल टेम्पलेट तर्क
C
Runtime deduction रनटाइम कटौती
D
Only for same types केवल एक ही प्रकार के लिए
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 CTAD: pair p{1, 2.0}; deduces pair via deduction guide.
व्याख्या (हिन्दी) सी++17 सीटीएडी: जोड़ी पी{1, 2.0}; डिडक्शन गाइड के माध्यम से जोड़ी निकाली जाती है।
549
EN + हिं
GB What is the output: unsigned x=10; int y=-1; cout<<(x+y);
IN आउटपुट क्या है: unsigned x=10; int y=-1; अदालत
A
9 9
B
Undefined अपरिभाषित
C
Compile error संकलन त्रुटि
D
UINT_MAX+9 UINT_MAX+9
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) y=-1 converted to unsigned=UINT_MAX. 10+UINT_MAX wraps: UINT_MAX+11... wait: 10+(UINT_MAX)=UINT_MAX+10 which wraps to 9 (since UINT_MAX+1=0, UINT_MAX+10=9). Output: 9.
व्याख्या (हिन्दी) y=-1 को अहस्ताक्षरित=UINT_MAX में परिवर्तित किया गया। 10+UINT_MAX रैप्स: UINT_MAX+11... प्रतीक्षा करें: 10+(UINT_MAX)=UINT_MAX+10 जो 9 तक रैप होता है (चूंकि UINT_MAX+1=0, UINT_MAX+10=9)। आउटपुट: 9.
550
EN + हिं
GB What is 'std::byte to integer' conversion?
IN 'std::बाइट से पूर्णांक' रूपांतरण क्या है?
A
std::to_integer<int>(b) — explicit conversion std::to_integer(b) - स्पष्ट रूपांतरण
B
Implicit cast निहित कास्ट
C
reinterpret_cast पुनर्व्याख्या_कास्ट
D
C-style cast सी-स्टाइल कास्ट
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::to_integer(b) explicitly converts std::byte to integer type.
व्याख्या (हिन्दी) std::to_integer(b) स्पष्ट रूप से std::byte को पूर्णांक प्रकार में परिवर्तित करता है।
551
EN + हिं
GB What is the output: char c='a'; c-=32; cout<
IN आउटपुट क्या है: char c='a'; सी-=32; अदालत
A
A
B
a
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 'a'=97-32=65='A'. Output: A.
व्याख्या (हिन्दी) 'ए'=97-32=65='ए'। आउटपुट: ए.
552
EN + हिं
GB What is 'std::variant::index()'?
IN 'std::variant::index()' क्या है?
A
Returns index of currently held type वर्तमान में रखे गए प्रकार का सूचकांक लौटाता है
B
Returns value मान लौटाता है
C
Returns type name प्रकार का नाम लौटाता है
D
Returns size आकार लौटाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) variant v=3.14; v.index() returns 2 (double is 3rd type, 0-indexed).
व्याख्या (हिन्दी) वैरिएंट v=3.14; v.index() रिटर्न 2 (डबल तीसरा प्रकार है, 0-अनुक्रमित)।
553
EN + हिं
GB What is the output: int a=5,b=3; cout<
IN आउटपुट क्या है: int a=5,b=3; अदालत
A
15 15
B
8 8
C
5 5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) max of initializer_list: max is 15=a*b. Output: 15.
व्याख्या (हिन्दी) इनिशियलाइज़र_लिस्ट की अधिकतम सीमा: अधिकतम 15=a*b है। आउटपुट: 15.
554
EN + हिं
GB What is 'scoped enum' (enum class)?
IN 'स्कोप्ड एनम' (एनम क्लास) क्या है?
A
Enum values scoped to enum name; no implicit int conversion Enum मानों का दायरा enum नाम तक सीमित है; कोई अंतर्निहित अंतर रूपांतरण नहीं
B
Same as regular enum नियमित एनम के समान
C
A class with enum members एनम सदस्यों वाला एक वर्ग
D
Template enum टेम्प्लेट एनम
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) enum class Color{Red,Green}; requires Color::Red; no implicit conversion to int.
व्याख्या (हिन्दी) एनम वर्ग रंग {लाल, हरा}; रंग की आवश्यकता है::लाल; int में कोई अंतर्निहित रूपांतरण नहीं।
555
EN + हिं
GB What is the output: enum class E{A=1,B=2,C=4}; cout<<(int)E::C;
IN आउटपुट क्या है: enum class E{A=1,B=2,C=4}; अदालत
A
4 4
B
2 2
C
3 3
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) E::C=4; (int)E::C=4. Output: 4.
व्याख्या (हिन्दी) ई::सी=4; (int)E::C=4. आउटपुट: 4.
541–555 of 1915