OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye

📚 160 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
160 questions
1
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++ में अपरिभाषित व्यवहार है।
2
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* एक सामान्य सूचक प्रकार है जो किसी भी ऑब्जेक्ट प्रकार के लिए सूचक को पकड़ सकता है, हालांकि इसे सीधे संदर्भित नहीं किया जा सकता है।
3
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.
4
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.
व्याख्या (हिन्दी) मानक केवल आकार(छोटा) की गारंटी देता है
5
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 के रूप में कैश कर सकता है।
6
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 दशमलव में.
7
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] उन्हें ब्लॉक स्कोप पर अप्रारंभीकृत छोड़ देता है।
8
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 है, जो किसी भी सूचक प्रकार या बूल में अंतर्निहित रूप से परिवर्तनीय है।
9
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।
10
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 के आसपास लपेटता है।
11
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 निकालता है।
12
EN + हिं
GB What is the size of: struct { char a; int b; char c; }?
IN इसका आकार क्या है: struct { char a; पूर्णांक बी; चार सी; }?
A
6 bytes 6 बाइट्स
B
12 bytes 12 बाइट्स
C
Implementation-defined due to padding पैडिंग के कारण कार्यान्वयन-परिभाषित
D
8 bytes on most platforms अधिकांश प्लेटफ़ॉर्म पर 8 बाइट्स
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Padding is inserted for alignment; on most 32-bit/64-bit platforms this struct is 12 bytes (1+3pad+4+1+3pad), but it is implementation-defined.
व्याख्या (हिन्दी) संरेखण के लिए पैडिंग डाली गई है; on most 32-bit/64-bit platforms this struct is 12 bytes (1+3pad+4+1+3pad), but it is implementation-defined.
13
EN + हिं
GB Which of these is NOT an integer type in C++?
IN इनमें से कौन सा C++ में पूर्णांक प्रकार नहीं है?
A
bool बूल
B
wchar_t wchar_t
C
float तैरना
D
char16_t char16_t
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) float is a floating-point type. bool, wchar_t, and char16_t are all integer types in C++.
व्याख्या (हिन्दी) फ्लोट एक फ्लोटिंग-पॉइंट प्रकार है। बूल, wchar_t, और char16_t सभी C++ में पूर्णांक प्रकार हैं।
14
EN + हिं
GB What is the output: int x=10; int &r=x; r=20; cout<
IN आउटपुट क्या है: int x=10; int &r=x; आर=20; अदालत
A
10 10
B
20 20
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) r is a reference to x. Assigning r=20 changes x to 20.
व्याख्या (हिन्दी) r, x का संदर्भ है। r=20 निर्दिष्ट करने से x 20 में बदल जाता है।
15
EN + हिं
GB What is 'structured binding' introduced in C++17?
IN C++17 में प्रस्तुत 'संरचित बाइंडिंग' क्या है?
A
Binding a struct to memory address किसी संरचना को मेमोरी एड्रेस से बाइंड करना
B
Decomposing an aggregate into named variables किसी समुच्चय को नामित चरों में विघटित करना
C
Binding references to struct members संरचना सदस्यों के लिए बाध्यकारी संदर्भ
D
Pointer to struct member संरचना सदस्य के लिए सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) auto [a,b] = pair; decomposes a pair/tuple/array/struct into individual named variables.
व्याख्या (हिन्दी) ऑटो [ए,बी] = जोड़ी; एक जोड़ी/टुपल/सरणी/संरचना को अलग-अलग नामित चर में विघटित करता है।
1–15 of 160