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
16
EN + हिं
GB What is the value of: int a = 010 + 0x10 + 10;
IN इसका मान क्या है: int a = 010 + 0x10 + 10;
A
30 30
B
34 34
C
42 42
D
36 36
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 010 is octal 8, 0x10 is hex 16, 10 is decimal 10. Sum = 8+16+10 = 34. Wait: 8+16=24, 24+10=34. Answer is 34.
व्याख्या (हिन्दी) 010 अष्टक 8 है, 0x10 हेक्स 16 है, 10 दशमलव 10 है। योग = 8+16+10 = 34। प्रतीक्षा करें: 8+16=24, 24+10=34। उत्तर 34 है.
17
EN + हिं
GB What is the maximum number of bytes a UTF-8 character can occupy?
IN एक UTF-8 कैरेक्टर अधिकतम कितनी बाइट्स ले सकता है?
A
2 2
B
3 3
C
4 4
D
6 6
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The current Unicode standard uses up to 4 bytes in UTF-8 (code points up to U+10FFFF).
व्याख्या (हिन्दी) वर्तमान यूनिकोड मानक UTF-8 में 4 बाइट्स (U+10FFFF तक कोड बिंदु) का उपयोग करता है।
18
EN + हिं
GB Which header must be included to use std::numeric_limits?
IN std::numeric_limits का उपयोग करने के लिए कौन सा हेडर शामिल किया जाना चाहिए?
A
<limits> <limits>
B
<climits> <climits>
C
<cfloat> <cfloat>
D
<numeric> <numeric>
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) std::numeric_limits is defined in the header in C++.
व्याख्या (हिन्दी) std::numeric_limits को C++ में हेडर में परिभाषित किया गया है।
19
EN + हिं
GB What is the output: cout << (1 == 1 == 1);
IN आउटपुट क्या है: cout
A
1 1
C
true सत्य
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (1==1) evaluates to true (1), then (1==1) becomes true, so output is 1.
व्याख्या (हिन्दी) (1==1) सत्य (1) का मूल्यांकन करता है, फिर (1==1) सत्य हो जाता है, इसलिए आउटपुट 1 है।
20
EN + हिं
GB In C++, which of the following has static storage duration?
IN C++ में, निम्न में से किसकी स्थिर भंडारण अवधि होती है?
A
Local variables inside functions फ़ंक्शंस के अंदर स्थानीय चर
B
Function parameters फ़ंक्शन पैरामीटर
C
Global variables सार्वत्रिक चर
D
Heap-allocated objects ढेर-आवंटित वस्तुएँ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Global variables (and static local variables, static data members) have static storage duration — they exist for the entire program lifetime.
व्याख्या (हिन्दी) वैश्विक चर (और स्थिर स्थानीय चर, स्थिर डेटा सदस्य) की स्थिर भंडारण अवधि होती है - वे पूरे कार्यक्रम जीवनकाल के लिए मौजूद रहते हैं।
21
EN + हिं
GB What is the output: int i=0; cout << i++ << i++;
IN आउटपुट क्या है: int i=0; अदालत
A
01 01
B
10 10
C
00 00
D
Undefined behavior अपरिभाषित व्यवहार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The order of evaluation of arguments to operator<< is unspecified before C++17, and modifying i twice is undefined behavior pre-C++17.
व्याख्या (हिन्दी) संचालक को तर्कों के मूल्यांकन का क्रम
22
EN + हिं
GB What is the purpose of the 'volatile' keyword in C++?
IN C++ में 'अस्थिर' कीवर्ड का उद्देश्य क्या है?
A
Prevents compiler optimization on a variable एक वेरिएबल पर कंपाइलर ऑप्टिमाइज़ेशन को रोकता है
B
Makes a variable thread-safe एक वैरिएबल थ्रेड-सुरक्षित बनाता है
C
Stores a variable in registers रजिस्टरों में एक वेरिएबल संग्रहीत करता है
D
Makes a constant variable एक स्थिर चर बनाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) volatile tells the compiler that the variable may be changed by external means (hardware, other thread), so every access must go to memory.
व्याख्या (हिन्दी) वोलेटाइल कंपाइलर को बताता है कि वेरिएबल को बाहरी माध्यमों (हार्डवेयर, अन्य थ्रेड) द्वारा बदला जा सकता है, इसलिए प्रत्येक एक्सेस को मेमोरी में जाना चाहिए।
23
EN + हिं
GB What is 'RAII' in C++?
IN C++ में 'RAII' क्या है?
A
Random Access Initialization Index रैंडम एक्सेस इनिशियलाइज़ेशन इंडेक्स
B
Resource Acquisition Is Initialization संसाधन अधिग्रहण आरंभीकरण है
C
Recursive Algorithm Implementation Index पुनरावर्ती एल्गोरिथम कार्यान्वयन सूचकांक
D
Runtime Array Initialization Interface रनटाइम ऐरे इनिशियलाइज़ेशन इंटरफ़ेस
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) RAII ties resource management to object lifetime; resources are acquired in constructor and released in destructor.
व्याख्या (हिन्दी) आरएआईआई संसाधन प्रबंधन को वस्तु जीवनकाल से जोड़ता है; संसाधनों को कंस्ट्रक्टर में अर्जित किया जाता है और डिस्ट्रक्टर में जारी किया जाता है।
24
EN + हिं
GB What is the output: int x=5,y=3; cout<<(x&y)<<' '<<(x|y)<<' '<<(x^y);
IN आउटपुट क्या है: int x=5,y=3; अदालत
A
1 7 6 1 7 6
B
5 3 6 5 3 6
C
1 5 6 1 5 6
D
3 7 5 3 7 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5=101, 3=011. AND=001=1, OR=111=7, XOR=110=6.
व्याख्या (हिन्दी) 5=101, 3=011. और=001=1, या=111=7, एक्सओआर=110=6।
25
EN + हिं
GB Which is the correct way to prevent a class from being instantiated directly in C++?
IN किसी क्लास को सीधे C++ में इंस्टेंटियेट होने से रोकने का सही तरीका कौन सा है?
A
Declare constructor as private कंस्ट्रक्टर को निजी घोषित करें
B
Mark class as final कक्षा को अंतिम के रूप में चिह्नित करें
C
Declare at least one pure virtual function कम से कम एक शुद्ध वर्चुअल फ़ंक्शन घोषित करें
D
Use abstract keyword अमूर्त कीवर्ड का प्रयोग करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Declaring at least one pure virtual function makes the class abstract and prevents direct instantiation.
व्याख्या (हिन्दी) कम से कम एक शुद्ध आभासी फ़ंक्शन की घोषणा करने से वर्ग अमूर्त हो जाता है और प्रत्यक्ष तात्कालिकता को रोकता है।
26
EN + हिं
GB What is the output: cout << sizeof(void*) == sizeof(int*);
IN आउटपुट क्या है: cout
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sizeof(void*) == sizeof(int*) is true (both are pointer types, same size). cout << true outputs 1.
व्याख्या (हिन्दी) sizeof(void*) == sizeof(int*) सत्य है (दोनों सूचक प्रकार हैं, समान आकार)। अदालत
27
EN + हिं
GB What does 'constexpr' guarantee?
IN 'constexpr' क्या गारंटी देता है?
A
Expression evaluated at compile time always अभिव्यक्ति का मूल्यांकन हमेशा संकलन समय पर किया जाता है
B
Expression CAN be evaluated at compile time संकलन समय पर अभिव्यक्ति का मूल्यांकन किया जा सकता है
C
Immutable variable अपरिवर्तनीय चर
D
Inlined function इनलाइन फ़ंक्शन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexpr means the expression is potentially evaluated at compile time; if used in constant context it must be, otherwise it may run at runtime.
व्याख्या (हिन्दी) constexpr का अर्थ है कि संकलन समय पर अभिव्यक्ति का संभावित मूल्यांकन किया जाता है; यदि निरंतर संदर्भ में इसका उपयोग किया जाता है तो यह अवश्य होना चाहिए, अन्यथा यह रनटाइम पर चल सकता है।
28
EN + हिं
GB What is the output: int arr[3]={1,2,3}; cout<
IN आउटपुट क्या है: int arr[3]={1,2,3}; अदालत
B
Compile error संकलन त्रुटि
C
Undefined behavior अपरिभाषित व्यवहार
D
Runtime exception क्रम अपवाद
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Accessing arr[5] is out of bounds — undefined behavior. No bounds checking for raw arrays.
व्याख्या (हिन्दी) गिरफ्तारी[5] तक पहुंच सीमा से बाहर है - अपरिभाषित व्यवहार। कच्चे सरणियों की जाँच की कोई सीमा नहीं।
29
EN + हिं
GB What is the meaning of 'ABI' in C++?
IN C++ में 'ABI' का क्या अर्थ है?
A
Abstract Binary Interface सार बाइनरी इंटरफ़ेस
B
Application Binary Interface एप्लिकेशन बाइनरी इंटरफ़ेस
C
Advanced Build Infrastructure उन्नत निर्माण अवसंरचना
D
Assembly Basic Instructions असेंबली के बुनियादी निर्देश
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ABI defines how compiled code interacts at the binary level — calling conventions, name mangling, vtable layout, etc.
व्याख्या (हिन्दी) एबीआई परिभाषित करता है कि संकलित कोड बाइनरी स्तर पर कैसे इंटरैक्ट करता है - कॉलिंग कन्वेंशन, नेम मैंगलिंग, वीटेबल लेआउट इत्यादि।
30
EN + हिं
GB Which operator cannot be overloaded in C++?
IN C++ में किस ऑपरेटर को ओवरलोड नहीं किया जा सकता है?
A
[] []
B
-> ->
C
:: ::
D
() ()
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The scope resolution operator :: cannot be overloaded in C++.
व्याख्या (हिन्दी) स्कोप रिज़ॉल्यूशन ऑपरेटर :: को C++ में ओवरलोड नहीं किया जा सकता है।
16–30 of 187