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
31
EN + हिं
GB What is the output: int x = -1; unsigned int y = x; cout << (y > 0);
IN आउटपुट क्या है: int x = -1; अहस्ताक्षरित int y = x; कोउट 0);
B
1 1
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) -1 converted to unsigned int becomes UINT_MAX (a large positive number), so y > 0 is true, output is 1.
व्याख्या (हिन्दी) -1 को अहस्ताक्षरित int में परिवर्तित करने पर UINT_MAX (एक बड़ी धनात्मक संख्या) बन जाती है, इसलिए y > 0 सत्य है, आउटपुट 1 है।
32
EN + हिं
GB What is a 'sequence point' in C++?
IN C++ में 'अनुक्रम बिंदु' क्या है?
A
A point where all side effects are complete एक ऐसा बिंदु जहां सभी दुष्प्रभाव पूर्ण हो जाते हैं
B
A semicolon in code कोड में एक अर्धविराम
C
A function call boundary एक फ़ंक्शन कॉल सीमा
D
A memory barrier एक स्मृति बाधा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A sequence point ensures all side effects of previous evaluations are complete before the next expression begins evaluation.
व्याख्या (हिन्दी) एक अनुक्रम बिंदु यह सुनिश्चित करता है कि अगली अभिव्यक्ति का मूल्यांकन शुरू होने से पहले पिछले मूल्यांकन के सभी दुष्प्रभाव पूरे हो जाएं।
33
EN + हिं
GB In C++, what does 'decltype(auto)' do?
IN C++ में, 'decltype(auto)' क्या करता है?
A
Deduces type like auto ऑटो जैसे प्रकार का अनुमान लगाता है
B
Deduces exact type including references संदर्भ सहित सटीक प्रकार का पता लगाता है
C
Only works with templates केवल टेम्प्लेट के साथ काम करता है
D
Equivalent to decltype डिक्ल्टाइप के समतुल्य
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) decltype(auto) deduces the type using decltype rules, preserving reference and cv-qualifiers, unlike plain auto which strips them.
व्याख्या (हिन्दी) decltype(auto) संदर्भ और cv-क्वालिफायर को संरक्षित करते हुए, decltype नियमों का उपयोग करके प्रकार का अनुमान लगाता है, सादे ऑटो के विपरीत जो उन्हें हटा देता है।
34
EN + हिं
GB What is the maximum value of a signed 32-bit integer?
IN हस्ताक्षरित 32-बिट पूर्णांक का अधिकतम मान क्या है?
A
2^32 - 1 2^32 - 1
B
2^31 2^31
C
2^31 - 1 2^31 - 1
D
2^32 2^32
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A signed 32-bit int stores values from -2^31 to 2^31-1, i.e., -2147483648 to 2147483647.
व्याख्या (हिन्दी) एक हस्ताक्षरित 32-बिट इंट -2^31 से 2^31-1 तक मान संग्रहीत करता है, अर्थात, -2147483648 से 2147483647 तक।
35
EN + हिं
GB What is the output: int x=INT_MIN; cout << -x;
IN आउटपुट क्या है: int x=INT_MIN; अदालत
A
INT_MAX INT_MAX
B
INT_MIN INT_MIN
D
Undefined behavior अपरिभाषित व्यवहार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Negating INT_MIN causes signed integer overflow, which is undefined behavior in C++.
व्याख्या (हिन्दी) INT_MIN को नकारने से हस्ताक्षरित पूर्णांक अतिप्रवाह होता है, जो C++ में अपरिभाषित व्यवहार है।
36
EN + हिं
GB Which type can hold a pointer to any object type?
IN कौन सा प्रकार किसी ऑब्जेक्ट प्रकार पर पॉइंटर रख सकता है?
A
void* खालीपन*
B
char* चार*
C
int* int*
D
nullptr_t nullptr_t
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) void* is a generic pointer type that can hold a pointer to any object type, though it cannot be dereferenced directly.
व्याख्या (हिन्दी) void* एक सामान्य सूचक प्रकार है जो किसी भी ऑब्जेक्ट प्रकार के लिए सूचक को पकड़ सकता है, हालांकि इसे सीधे संदर्भित नहीं किया जा सकता है।
37
EN + हिं
GB What is the value of: auto x = 3.14f; decltype(x) y = 2; cout << sizeof(y);
IN इसका मान क्या है: ऑटो x = 3.14f; decltype(x) y = 2; अदालत
A
4 4
B
8 8
C
2 2
D
Depends on platform प्लेटफार्म पर निर्भर करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3.14f is float, so x is float. decltype(x) is float. sizeof(float) = 4.
व्याख्या (हिन्दी) 3.14f फ्लोट है, इसलिए x फ्लोट है। decltype(x) फ्लोट है। आकार(फ्लोट) = 4.
38
EN + हिं
GB What is the difference between int and long in C++?
IN C++ में int और long के बीच क्या अंतर है?
A
long is always 64-bit long हमेशा 64-बिट होता है
B
int is always 32-bit int हमेशा 32-बिट होता है
C
sizeof(long) >= sizeof(int) is guaranteed sizeof(long) >= sizeof(int) की गारंटी है
D
They are identical वे समान हैं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The standard only guarantees sizeof(short)<=sizeof(int)<=sizeof(long)<=sizeof(long long). Exact sizes are implementation-defined.
व्याख्या (हिन्दी) मानक केवल आकार(छोटा) की गारंटी देता है
39
EN + हिं
GB What happens: const int x = 5; int* p = const_cast(&x); *p = 10; cout << x;
IN क्या होता है: const int x = 5; int* p = const_cast(&x); *पी = 10; अदालत
A
10 10
B
5 5
C
Undefined behavior अपरिभाषित व्यवहार
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Modifying a const object through const_cast is undefined behavior; the compiler may cache the value of x as 5.
व्याख्या (हिन्दी) const_cast के माध्यम से किसी const ऑब्जेक्ट को संशोधित करना अपरिभाषित व्यवहार है; कंपाइलर x का मान 5 के रूप में कैश कर सकता है।
40
EN + हिं
GB What is the output: int x = 0b1010; cout << x;
IN आउटपुट क्या है: int x = 0b1010; अदालत
A
1010 1010
B
10 10
C
8 8
D
Compile error (pre C++14) संकलन त्रुटि (पूर्व C++14)
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Binary literals (0b prefix) are supported in C++14+. 0b1010 = 10 in decimal.
व्याख्या (हिन्दी) C++14+ में बाइनरी अक्षर (0b उपसर्ग) समर्थित हैं। 0b1010 = 10 दशमलव में.
41
EN + हिं
GB Which of these correctly initializes all elements to zero?
IN इनमें से कौन सभी तत्वों को शून्य पर सही ढंग से प्रारंभ करता है?
A
int arr[5]; int गिरफ्तारी[5];
B
int arr[5] = {}; पूर्णांक गिरफ्तारी[5] = {};
C
int arr[5] = {0}; पूर्णांक गिरफ्तारी[5] = {0};
D
Both B and C बी और सी दोनों
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int arr[5]={} and int arr[5]={0} both value-initialize all elements to 0. Plain int arr[5] leaves them uninitialized at block scope.
व्याख्या (हिन्दी) int arr[5]={} और int arr[5]={0} दोनों सभी तत्वों को 0 पर मान-प्रारंभ करते हैं। सादा int arr[5] उन्हें ब्लॉक स्कोप पर अप्रारंभीकृत छोड़ देता है।
42
EN + हिं
GB What is the type of 'nullptr' in C++11?
IN C++11 में 'nullptr' का प्रकार क्या है?
A
void* खालीपन*
B
int int यहाँ
C
std::nullptr_t std::nullptr_t
D
NULL व्यर्थ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) nullptr has type std::nullptr_t, which is implicitly convertible to any pointer type or bool.
व्याख्या (हिन्दी) nullptr का प्रकार std::nullptr_t है, जो किसी भी सूचक प्रकार या बूल में अंतर्निहित रूप से परिवर्तनीय है।
43
EN + हिं
GB What is the output: double d = 1/3; cout << d;
IN आउटपुट क्या है: डबल डी = 1/3; अदालत
A
0.333333 0.333333
C
0.0 0.0
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1/3 is integer division (both operands are int), result is 0. Then 0 is assigned to double d, so d = 0.0.
व्याख्या (हिन्दी) 1/3 पूर्णांक विभाजन है (दोनों ऑपरेंड पूर्णांक हैं), परिणाम 0 है। फिर 0 को डबल डी को सौंपा गया है, इसलिए डी = 0.0।
44
EN + हिं
GB What is the result: unsigned char x = 255; x++; cout << x;
IN परिणाम क्या है: अहस्ताक्षरित चार x = 255; एक्स++; अदालत
A
256 256
B
255 255
D
Undefined behavior अपरिभाषित व्यवहार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Unsigned integer overflow is well-defined and wraps around: 255+1 = 0 for unsigned char.
व्याख्या (हिन्दी) अहस्ताक्षरित पूर्णांक अतिप्रवाह अच्छी तरह से परिभाषित है और अहस्ताक्षरित चार के लिए 255+1 = 0 के आसपास लपेटता है।
45
EN + हिं
GB What does 'auto' deduce for: auto x = {1,2,3};
IN 'ऑटो' किसके लिए निष्कर्ष निकालता है: ऑटो x = {1,2,3};
A
int[] int[]
B
std::vector<int> एसटीडी::वेक्टर
C
std::initializer_list<int> std::initializer_list
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) auto with a braced initializer list deduces std::initializer_list.
व्याख्या (हिन्दी) ब्रेस्ड इनिशियलाइज़र सूची के साथ ऑटो std::initializer_list निकालता है।
31–45 of 1915