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
46
EN + हिं
GB What is 'extern' keyword for variables?
IN वेरिएबल के लिए 'बाहरी' कीवर्ड क्या है?
A
Declares variable defined elsewhere (no storage allocated) अन्यत्र परिभाषित चर की घोषणा करता है (कोई संग्रहण आवंटित नहीं)
B
Defines global variable वैश्विक चर को परिभाषित करता है
C
Makes variable const परिवर्तनीय स्थिरांक बनाता है
D
Hides variable परिवर्तनशील छुपाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) extern int x; declares x without defining; linker finds definition in another TU.
व्याख्या (हिन्दी) बाहरी पूर्णांक x; परिभाषित किए बिना x घोषित करता है; लिंकर को किसी अन्य TU में परिभाषा मिलती है।
47
EN + हिं
GB What is the output: int x=5; cout<<(x|(x<<1));
IN आउटपुट क्या है: int x=5; अदालत
A
15 15
B
5 5
C
10 10
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5=101, 5<<1=1010. 101|1010=1111=15. Output: 15.
व्याख्या (हिन्दी) 5=101, 5
48
EN + हिं
GB What is 'address sanitizer'?
IN 'एड्रेस सैनिटाइजर' क्या है?
A
Runtime tool detecting memory errors (OOB, use-after-free) मेमोरी त्रुटियों का पता लगाने वाला रनटाइम टूल (ओओबी, उपयोग-बाद-मुक्त)
B
A debugger एक डिबगर
C
A profiler एक प्रोफाइलर
D
A linter एक लिंटर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) AddressSanitizer (ASan) instruments code to detect buffer overflows, use-after-free, etc. at runtime.
व्याख्या (हिन्दी) रनटाइम पर बफर ओवरफ्लो, उपयोग-बाद-मुक्त आदि का पता लगाने के लिए एड्रेससैनिटाइज़र (एएसएएन) उपकरण कोड।
49
EN + हिं
GB What is the output: for(int i=1;i<6;i++) cout<<(i*i-1)/(i+1)+1;
IN आउटपुट क्या है: for(int i=1;i
A
12345 12345
B
23456 23456
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (i^2-1)/(i+1)=(i-1)(i+1)/(i+1)=i-1. i-1+1=i. Prints 1,2,3,4,5. Output: 12345.
व्याख्या (हिन्दी) (i^2-1)/(i+1)=(i-1)(i+1)/(i+1)=i-1. मैं-1+1=मैं. 1,2,3,4,5 प्रिंट करता है। आउटपुट: 12345.
50
EN + हिं
GB What is the output: int x=0; auto f=[&]{x=42;}; f(); cout<
IN आउटपुट क्या है: int x=0; ऑटो f=[&]{x=42;}; एफ(); अदालत
A
42 42
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f() modifies x via ref capture. x=42. Output: 42.
व्याख्या (हिन्दी) f() रेफ कैप्चर के माध्यम से x को संशोधित करता है। एक्स=42. आउटपुट: 42.
51
EN + हिं
GB What is 'std::as_const'?
IN 'std::as_const' क्या है?
A
Returns const reference to argument तर्क का स्थिर संदर्भ लौटाता है
B
Casts to const pointer कॉन्स्ट पॉइंटर पर कास्ट करता है
C
Removes const स्थिरांक हटाता है
D
Makes constexpr constexpr बनाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::as_const(x) returns const T& to x; useful for calling const overloads explicitly.
व्याख्या (हिन्दी) std::as_const(x) स्थिरांक T& को x पर लौटाता है; कॉन्स्ट ओवरलोड को स्पष्ट रूप से कॉल करने के लिए उपयोगी।
52
EN + हिं
GB What is the output: int x=5; cout<<(-(-x));
IN आउटपुट क्या है: int x=5; अदालत
A
5 5
B
-5 -5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (1, 6, 71, 1, 4, 'What is 'undefined behavior sanitizer'?
व्याख्या (हिन्दी) (1, 6, 71, 1, 4, 'अपरिभाषित व्यवहार सैनिटाइज़र' क्या है?
53
EN + हिं
GB What is 'undefined behavior sanitizer'?
IN 'अपरिभाषित व्यवहार सैनिटाइज़र' क्या है?
A
Runtime tool detecting UB (signed overflow, null deref, etc.) यूबी का पता लगाने वाला रनटाइम टूल (हस्ताक्षरित ओवरफ़्लो, नल डेरेफ़, आदि)
B
Same as ASan आसन के समान
C
A compiler flag एक संकलक ध्वज
D
A linker option एक लिंकर विकल्प
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) UBSan instruments code to detect undefined behavior at runtime with detailed diagnostics.
व्याख्या (हिन्दी) विस्तृत निदान के साथ रनटाइम पर अपरिभाषित व्यवहार का पता लगाने के लिए यूबीएसएन उपकरण कोड।
54
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.
55
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 के समतुल्य।
56
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.
57
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 पर सेट करता है; स्थिर चर के लिए और स्पष्ट रूप से {} के साथ होता है।
58
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__ पूर्वनिर्धारित स्ट्रिंग शाब्दिक है जिसमें वर्तमान फ़ंक्शन नाम शामिल है। आउटपुट: मुख्य.
59
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++ में कार्यान्वयन-परिभाषित।
60
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.
46–60 of 187