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
16
EN + हिं
GB What is the output: int a=5; int b=a; b=10; cout<
IN आउटपुट क्या है: int a=5; int b=a; बी=10; अदालत
A
10 10
B
5 5
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b is a copy of a, not a reference. Changing b does not affect a.
व्याख्या (हिन्दी) b, a की प्रतिलिपि है, संदर्भ नहीं। b बदलने से a पर कोई प्रभाव नहीं पड़ता।
17
EN + हिं
GB Which storage class specifier makes a local variable persist between function calls?
IN कौन सा स्टोरेज क्लास स्पेसिफायर फ़ंक्शन कॉल के बीच स्थानीय वैरिएबल को बनाए रखता है?
A
auto ऑटो
B
register पंजीकरण करवाना
C
static स्थिर
D
extern बाहरी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) static local variables are initialized once and retain their value between function calls.
व्याख्या (हिन्दी) स्थैतिक स्थानीय चर को एक बार प्रारंभ किया जाता है और फ़ंक्शन कॉल के बीच उनका मान बनाए रखा जाता है।
18
EN + हिं
GB What is the output: int x=1; cout<<(x<<31);
IN आउटपुट क्या है: int x=1; अदालत
A
2147483648 2147483648
B
INT_MIN INT_MIN
C
Undefined behavior अपरिभाषित व्यवहार
D
-1 -1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Left-shifting 1 into the sign bit of a signed integer is undefined behavior in C++ (prior to C++20).
व्याख्या (हिन्दी) किसी हस्ताक्षरित पूर्णांक के साइन बिट में 1 को लेफ्ट-शिफ्ट करना C++ (C++20 से पहले) में अपरिभाषित व्यवहार है।
19
EN + हिं
GB What is the difference between int* const p and const int* p?
IN int* const p और const int* p के बीच क्या अंतर है?
A
No difference कोई फर्क नहीं
B
int* const: pointer is const; const int*: pointee is const int* स्थिरांक: सूचक स्थिरांक है; स्थिरांक int*: पॉइंटी स्थिरांक है
C
int* const: pointee is const; const int*: pointer is const int* स्थिरांक: पॉइंटी स्थिरांक है; स्थिरांक int*: सूचक स्थिरांक है
D
Both are compile errors दोनों संकलन त्रुटियाँ हैं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int* const p — the pointer itself is const (can't reassign p). const int* p — the pointed-to value is const (can't modify *p).
व्याख्या (हिन्दी) int* const p - सूचक स्वयं स्थिरांक है (p को पुन: असाइन नहीं किया जा सकता)। const int* p - पॉइंट-टू मान स्थिरांक है (*p को संशोधित नहीं किया जा सकता)।
20
EN + हिं
GB What is the output: bool b = true; cout << b + b;
IN आउटपुट क्या है: bool b = true; अदालत
A
truetrue सच सच
B
2 2
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) bool is promoted to int in arithmetic: true=1, so 1+1=2.
व्याख्या (हिन्दी) अंकगणित में बूल को int में पदोन्नत किया गया है: true=1, इसलिए 1+1=2।
21
EN + हिं
GB What is the value of: int x = 'a'; cout << x;
IN इसका मान क्या है: int x = 'a'; अदालत
A
a
B
97 97
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The ASCII value of 'a' is 97. Assigning char to int stores its numeric value; cout<
व्याख्या (हिन्दी) 'ए' का ASCII मान 97 है। char को int में निर्दिष्ट करना इसके संख्यात्मक मान को संग्रहीत करता है; अदालत
22
EN + हिं
GB What does 'register' keyword do in modern C++?
IN आधुनिक C++ में 'रजिस्टर' कीवर्ड क्या करता है?
A
Forces variable into CPU register सीपीयू रजिस्टर में वेरिएबल को बाध्य करता है
B
Deprecated, no effect बहिष्कृत, कोई प्रभाव नहीं
C
Makes variable faster परिवर्तनशील को तेज़ बनाता है
D
Compile error in C++17 C++17 में संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) The register keyword was deprecated in C++11 and removed (made a reserved keyword) in C++17; using it causes a compile error.
व्याख्या (हिन्दी) रजिस्टर कीवर्ड को C++11 में हटा दिया गया और C++17 में हटा दिया गया (एक आरक्षित कीवर्ड बना दिया गया); इसका उपयोग करने से संकलन त्रुटि उत्पन्न होती है।
23
EN + हिं
GB What is the type deduced by: auto& x = 42;
IN किस प्रकार से निष्कर्ष निकाला जाता है: auto& x = 42;
A
int int यहाँ
B
int& int&
C
const int& स्थिरांक int&
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) You cannot bind a non-const lvalue reference to an rvalue (42 is an rvalue). This is a compile error.
व्याख्या (हिन्दी) आप एक गैर-कॉन्स्ट लैवल्यू संदर्भ को एक प्रतिद्वंद्विता (42 एक प्रतिद्वंद्विता है) से नहीं बांध सकते। यह एक संकलन त्रुटि है.
24
EN + हिं
GB What is the output: int x=10; cout<
IN आउटपुट क्या है: int x=10; अदालत
A
3 1 3 1
B
3 2 3 2
C
4 0 4 0
D
3 0 3 0
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10/3=3 (integer division truncates toward zero), 10%3=1.
व्याख्या (हिन्दी) 10/3=3 (पूर्णांक विभाजन शून्य की ओर छोटा हो जाता है), 10%3=1।
25
EN + हिं
GB What is 'POD type' in C++?
IN C++ में 'POD प्रकार' क्या है?
A
Plain Old Data — a type compatible with C data layout सादा पुराना डेटा - सी डेटा लेआउट के साथ संगत एक प्रकार
B
Polymorphic Object Data बहुरूपी वस्तु डेटा
C
Pointer Or Dereference type सूचक या Dereference प्रकार
D
Preprocessor Object Definition प्रीप्रोसेसर ऑब्जेक्ट परिभाषा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) POD (Plain Old Data) types have trivial constructors/destructors and standard layout, compatible with C structs.
व्याख्या (हिन्दी) पीओडी (प्लेन ओल्ड डेटा) प्रकारों में तुच्छ कंस्ट्रक्टर/डिस्ट्रक्टर और मानक लेआउट होते हैं, जो सी स्ट्रक्चर के साथ संगत होते हैं।
26
EN + हिं
GB What is the output: char c='Z'-'A'; cout<<(int)c;
IN आउटपुट क्या है: char c='Z'-'A'; अदालत
A
1 1
B
25 25
C
90 90
D
65 65
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 'Z' is 90, 'A' is 65, difference is 25.
व्याख्या (हिन्दी) 'Z' 90 है, 'A' 65 है, अंतर 25 है।
27
EN + हिं
GB Which of the following correctly declares a variable of type 'pointer to array of 5 ints'?
IN निम्नलिखित में से कौन सा 'पॉइंटर टू ऐरे ऑफ़ 5 इनट्स' प्रकार के वेरिएबल को सही ढंग से घोषित करता है?
A
int *p[5] पूर्णांक *पी[5]
B
int (*p)[5] पूर्णांक (*पी)[5]
C
int p[5]* पूर्णांक पी[5]*
D
int& p[5] पूर्णांक&पी[5]
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int (*p)[5] declares p as a pointer to an array of 5 ints. int *p[5] is an array of 5 int pointers.
व्याख्या (हिन्दी) int (*p)[5] p को 5 ints की सरणी के सूचक के रूप में घोषित करता है। int *p[5] 5 int पॉइंटर्स की एक सरणी है।
28
EN + हिं
GB What is the output: int x=5; cout << (x>3 ? x<10 ? 'A' : 'B' : 'C');
IN आउटपुट क्या है: int x=5; कॉउट 3? एक्स
A
A
B
B बी
C
C सी
D
65 65
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x>3 is true, then x<10 is true, so result is 'A' (ASCII 65 printed as char 'A').
व्याख्या (हिन्दी) x>3 सत्य है, तो x
29
EN + हिं
GB What is the output: double x = 0.1 + 0.2; cout << (x == 0.3);
IN आउटपुट क्या है: डबल x = 0.1 + 0.2; अदालत
A
1 1
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Floating-point representation errors make 0.1+0.2 != 0.3 exactly; the comparison returns false (0).
व्याख्या (हिन्दी) फ़्लोटिंग-पॉइंट प्रतिनिधित्व त्रुटियाँ 0.1+0.2 != 0.3 बिल्कुल बनाती हैं; तुलना गलत (0) लौटाती है।
30
EN + हिं
GB What is 'narrowing conversion' in C++?
IN C++ में 'संकीर्ण रूपांतरण' क्या है?
A
Converting larger type to smaller type बड़े प्रकार को छोटे प्रकार में परिवर्तित करना
B
Any implicit conversion कोई भी अंतर्निहित रूपांतरण
C
Converting float to int फ्लोट को इंट में परिवर्तित करना
D
A conversion that may lose information एक रूपांतरण जिसमें जानकारी खो सकती है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Narrowing conversions (like double to int) may lose information and are not allowed in list initialization {}.
व्याख्या (हिन्दी) रूपांतरणों को संक्षिप्त करने से (जैसे डबल से इंट तक) जानकारी खो सकती है और सूची आरंभीकरण {} में इसकी अनुमति नहीं है।
16–30 of 160