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

Question 196

EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *p=a+2; cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *p=a+2; अदालत
234 234
345 345
123 123
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p=a+2=&a[2]. p[-1]=a[1]=2, p[0]=a[2]=3, p[1]=a[3]=4. Output: 234.
व्याख्या (हिन्दी) पी=ए+2=&ए[2]. पी[-1]=ए[1]=2, पी[0]=ए[2]=3, पी[1]=ए[3]=4। आउटपुट: 234.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 197

EN + हिं
GB What is the output: void* p=(void*)42; cout<<(int)(size_t)p;
IN आउटपुट क्या है: void* p=(void*)42; अदालत
42 42
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Casting integer to void* and back is implementation-defined; on most platforms returns 42.
व्याख्या (हिन्दी) पूर्णांक को void* और वापस कास्ट करना कार्यान्वयन-परिभाषित है; अधिकांश प्लेटफ़ॉर्म पर 42 रिटर्न मिलता है।
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 198

EN + हिं
GB What is a 'smart pointer' in C++?
IN C++ में 'स्मार्ट पॉइंटर' क्या है?
A pointer with automatic memory management स्वचालित मेमोरी प्रबंधन वाला एक सूचक
A pointer to a class किसी वर्ग के लिए सूचक
A faster raw pointer एक तेज़ कच्चा सूचक
A compile-time pointer एक संकलन-समय सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Smart pointers (unique_ptr, shared_ptr, weak_ptr) manage heap memory automatically through RAII.
व्याख्या (हिन्दी) स्मार्ट पॉइंटर्स (यूनिक_पीटीआर, शेयर्ड_पीटीआर, वीक_पीटीआर) आरएआईआई के माध्यम से हीप मेमोरी को स्वचालित रूप से प्रबंधित करते हैं।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 199

EN + हिं
GB What is the output: int x=10; const int *p=&x; *p=20; cout<
IN आउटपुट क्या है: int x=10; स्थिरांक int *p=&x; *पी=20; अदालत
10 10
20 20
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p is pointer to const int; *p=20 tries to modify through const pointer: compile error.
व्याख्या (हिन्दी) p const int का सूचक है; *p=20 कॉन्स्ट पॉइंटर के माध्यम से संशोधित करने का प्रयास करता है: संकलन त्रुटि।
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 200

EN + हिं
GB What is the output: int x=5,y=10; int *p=&x; swap(p,&y); cout<
IN आउटपुट क्या है: int x=5,y=10; int *p=&x; स्वैप (पी,&वाई); अदालत
Undefined अपरिभाषित
5 10 5 10
Compile error संकलन त्रुटि
10 5 10 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) swap(p, &y) — p is int*, &y is int*. Types match; swaps p to point to y. x and y values unchanged. Actually this is swapping the pointer, not the values. So x=5,y=10 unchanged. Wait, std::swap on pointers swaps what they point to — no, it swaps the pointers themselves. cout<
व्याख्या (हिन्दी) स्वैप(p, &y) - p int* है, &y int* है। प्रकार मेल खाते हैं; Y को इंगित करने के लिए p को स्वैप करता है। x और y मान अपरिवर्तित हैं। दरअसल यह पॉइंटर की अदला-बदली है, मूल्यों की नहीं। तो x=5,y=10 अपरिवर्तित। रुको, पॉइंटर्स पर std::swap वे जो इंगित करते हैं उसे स्वैप करता है - नहीं, यह पॉइंटर्स को स्वयं स्वैप करता है। अदालत
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 201

EN + हिं
GB What is 'double pointer' in C++?
IN C++ में 'डबल पॉइंटर' क्या है?
Pointer to a pointer सूचक को सूचक
Pointer to double type डबल टाइप करने के लिए सूचक
Two pointers दो सूचक
64-bit pointer 64-बिट सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A double pointer (int**) stores the address of another pointer.
व्याख्या (हिन्दी) एक डबल पॉइंटर (int**) दूसरे पॉइंटर का पता संग्रहीत करता है।
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 202

EN + हिं
GB What is the output: int arr[]={1,2,3}; int *p=arr; cout<
IN आउटपुट क्या है: int arr[]={1,2,3}; int *p=arr; अदालत
Address 2 पता 2
1 2 1 2
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p++ and *p in same cout without sequencing (pre-C++17) is unspecified/undefined behavior.
व्याख्या (हिन्दी) p++ और *p अनुक्रमण के बिना एक ही कॉउट में (पूर्व-C++17) अनिर्दिष्ट/अपरिभाषित व्यवहार है।
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 203

EN + हिं
GB What is the output: int x=10; int &r=x; int *p=&r; *p=20; cout<
IN आउटपुट क्या है: int x=10; int &r=x; int *p=&r; *पी=20; अदालत
10 10
20 20
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) &r is the address of x (reference aliases x). *p=20 sets x=20. Output: 20.
व्याख्या (हिन्दी) &r x (संदर्भ उपनाम x) का पता है। *p=20 सेट x=20. आउटपुट: 20.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 204

EN + हिं
GB What is 'placement new' in C++?
IN C++ में 'प्लेसमेंट न्यू' क्या है?
Allocates on stack स्टैक पर आवंटित करता है
Constructs object at specified memory address निर्दिष्ट मेमोरी पते पर ऑब्जेक्ट का निर्माण करता है
Replaces global new वैश्विक नए की जगह लेता है
Only for arrays केवल सरणियों के लिए
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Placement new: new(ptr) T(args) constructs object at given memory without allocation.
व्याख्या (हिन्दी) प्लेसमेंट नया: new(ptr) T(args) आवंटन के बिना दी गई मेमोरी पर ऑब्जेक्ट का निर्माण करता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 205

EN + हिं
GB What is the output: int x=5; int *p=&x; cout<<**&p;
IN आउटपुट क्या है: int x=5; int *p=&x; अदालत
Address पता
5 5
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) &p is address of pointer p. *&p = p (the pointer). *(*&p) = *p = x = 5.
व्याख्या (हिन्दी) &p पॉइंटर पी का पता है। *&p = p (सूचक)। *(*&p) = *p = x = 5.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 206

EN + हिं
GB What does 'delete[]' do vs 'delete'?
IN 'डिलीट[]' बनाम 'डिलीट' क्या करता है?
delete[] frees array, delete frees single object हटाएँ[] सरणी को मुक्त करता है, हटाएँ एकल वस्तु को मुक्त करता है
They are identical वे समान हैं
delete[] is for vectors delete[] वैक्टर के लिए है
delete[] calls destructor once delete[] डिस्ट्रक्टर को एक बार कॉल करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) delete[] calls destructor for each element and frees the array; delete only calls destructor once.
व्याख्या (हिन्दी) हटाएं[] प्रत्येक तत्व के लिए विध्वंसक को कॉल करता है और सरणी को मुक्त करता है; कॉल डिस्ट्रक्टर को केवल एक बार हटाएं।
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 207

EN + हिं
GB What is the output: int* p=new int(42); cout<<*p; delete p; cout<<*p;
IN आउटपुट क्या है: int* p=new int(42); अदालत
42 42 42 42
42 0 42 0
42 then UB 42 फिर यूबी
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Accessing memory after delete is undefined behavior (use-after-free).
व्याख्या (हिन्दी) डिलीट के बाद मेमोरी तक पहुंच अपरिभाषित व्यवहार (उपयोग-बाद-मुक्त) है।
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 208

EN + हिं
GB What is 'wild pointer'?
IN 'वाइल्ड पॉइंटर' क्या है?
Uninitialized pointer अप्रारंभीकृत सूचक
Null pointer नल पॉइंटर
Pointer past array end सूचक पिछले सरणी अंत
Pointer to global वैश्विक की ओर सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A wild pointer is an uninitialized pointer that may point to arbitrary memory location.
व्याख्या (हिन्दी) वाइल्ड पॉइंटर एक अप्रारंभीकृत पॉइंटर है जो मनमाने ढंग से मेमोरी स्थान को इंगित कर सकता है।
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 209

EN + हिं
GB What is the output: int a=1,b=2; int *p=&a,*q=&b; *p=*q; cout<
IN आउटपुट क्या है: int a=1,b=2; int *p=&a,*q=&b; *पी=*क्यू; अदालत
22 22
12 12
21 21
11 11
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p=*q copies value of b into a. a becomes 2, b stays 2. Output: 22.
व्याख्या (हिन्दी) *p=*q b के मान को a में कॉपी करता है। ए 2 हो जाता है, बी 2 रहता है। आउटपुट: 22।
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 210

EN + हिं
GB What is the output: int x=5; int *p=&x; p=nullptr; cout<<(p?*p:0);
IN आउटपुट क्या है: int x=5; int *p=&x; p=nullptr; अदालत
5 5
Undefined अपरिभाषित
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p is set to nullptr; (p?*p:0): p is false, returns 0.
व्याख्या (हिन्दी) p को nullptr पर सेट किया गया है; (पी?*पी:0): पी गलत है, 0 लौटाता है।
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।