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
211
EN + हिं
GB What is std::unique_ptr?
IN std::unique_ptr क्या है?
A
Shared ownership smart pointer साझा स्वामित्व स्मार्ट सूचक
B
Exclusive ownership smart pointer (non-copyable) विशिष्ट स्वामित्व स्मार्ट पॉइंटर (गैर-प्रतिलिपि योग्य)
C
Weak reference smart pointer कमजोर संदर्भ स्मार्ट सूचक
D
Raw pointer wrapper कच्चा सूचक आवरण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) unique_ptr has exclusive ownership; it cannot be copied, only moved; deletes object on destruction.
व्याख्या (हिन्दी) अद्वितीय_पीटीआर के पास विशेष स्वामित्व है; इसे कॉपी नहीं किया जा सकता, केवल स्थानांतरित किया जा सकता है; नष्ट होने पर वस्तु को हटा देता है।
212
EN + हिं
GB What is the output: int a[]={10,20,30}; int *p=a; cout<<*(p++);
IN आउटपुट क्या है: int a[]={10,20,30}; int *p=a; अदालत
A
10 10
B
20 20
C
30 30
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p++ returns current p (pointing to a[0]=10), then increments. Dereferences to 10.
व्याख्या (हिन्दी) p++ वर्तमान p लौटाता है (a[0]=10 की ओर इंगित करता है), फिर वृद्धि करता है। 10 से सन्दर्भ.
213
EN + हिं
GB What is 'pointer to function' in C++?
IN C++ में 'पॉइंटर टू फंक्शन' क्या है?
A
A variable storing address of a function किसी फ़ंक्शन का एक वैरिएबल भंडारण पता
B
A function returning pointer एक फ़ंक्शन रिटर्निंग पॉइंटर
C
A member function pointer एक सदस्य फ़ंक्शन सूचक
D
A lambda एक लैम्ब्डा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Function pointers store the address of a function and can be used to call it indirectly.
व्याख्या (हिन्दी) फ़ंक्शन पॉइंटर्स किसी फ़ंक्शन का पता संग्रहीत करते हैं और इसे अप्रत्यक्ष रूप से कॉल करने के लिए उपयोग किया जा सकता है।
214
EN + हिं
GB What is the output: int f(){return 42;} int (*p)()=f; cout<
IN आउटपुट क्या है: int f(){return 42;} int (*p)()=f; अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p is function pointer to f; p() calls f() which returns 42.
व्याख्या (हिन्दी) p, f का फ़ंक्शन सूचक है; p() f() को कॉल करता है जो 42 लौटाता है।
215
EN + हिं
GB What is the output: int x=10; void *p=&x; cout<<*(int*)p;
IN आउटपुट क्या है: int x=10; शून्य *p=&x; अदालत
A
10 10
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) void* p stores address of x; cast to int* and dereference gives 10.
व्याख्या (हिन्दी) void* p, x का पता संग्रहीत करता है; int* पर कास्ट करें और डीरेफ़रेंस 10 देता है।
216
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *p=a+5; cout<<*(p-1);
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *p=a+5; अदालत
A
5 5
B
4 4
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p=a+5 (one past end). p-1=&a[4]. *(p-1)=5.
व्याख्या (हिन्दी) p=a+5 (एक पिछला छोर)। पी-1=&ए[4]. *(पी-1)=5.
217
EN + हिं
GB What is shared_ptr reference count?
IN Shared_ptr संदर्भ संख्या क्या है?
A
Number of shared_ptrs owning the object ऑब्जेक्ट के स्वामित्व वाले share_ptrs की संख्या
B
Number of times pointer is used पॉइंटर का उपयोग कितनी बार किया गया है
C
Garbage collection metric कचरा संग्रहण मीट्रिक
D
Memory address स्मृति पता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) shared_ptr maintains a reference count; when it drops to 0, the managed object is deleted.
व्याख्या (हिन्दी) Shared_ptr एक संदर्भ गणना बनाए रखता है; जब यह 0 पर गिरता है, तो प्रबंधित ऑब्जेक्ट हटा दिया जाता है।
218
EN + हिं
GB What is the output: int x=5; auto p=make_unique(x); *p=10; cout<
IN आउटपुट क्या है: int x=5; ऑटो p=make_unique(x); *पी=10; अदालत
A
5 5
B
10 10
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) make_unique creates a new int with value x (copy). *p=10 doesn't affect x. Output: 5.
व्याख्या (हिन्दी) make_unique मान x (कॉपी) के साथ एक नया int बनाता है। *p=10 x को प्रभावित नहीं करता. आउटपुट: 5.
219
EN + हिं
GB What is 'aliasing' in the context of pointers?
IN सूचकों के संदर्भ में 'अलियासिंग' क्या है?
A
Two pointers pointing to the same memory एक ही मेमोरी की ओर इशारा करने वाले दो संकेतक
B
A typedef for pointer type सूचक प्रकार के लिए एक टाइपडिफ़
C
Pointer casting सूचक कास्टिंग
D
Reference to pointer सूचक का संदर्भ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Pointer aliasing occurs when two different pointers point to the same memory location, which can affect optimization.
व्याख्या (हिन्दी) पॉइंटर अलियासिंग तब होता है जब दो अलग-अलग पॉइंटर एक ही मेमोरी लोकेशन की ओर इशारा करते हैं, जो अनुकूलन को प्रभावित कर सकता है।
220
EN + हिं
GB What is the output: int* p=new int[5]{1,2,3,4,5}; cout<
IN आउटपुट क्या है: int* p=new int[5]{1,2,3,4,5}; अदालत
A
5 5
B
4 4
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) new int[5]{1,2,3,4,5} initializes array; p[4]=5.
व्याख्या (हिन्दी) नया int[5]{1,2,3,4,5} सरणी प्रारंभ करता है; पी[4]=5.
221
EN + हिं
GB What is the output: class A{public: int x=5;}; A a; cout<
IN आउटपुट क्या है: class A{public: int x=5;}; ए ए; अदालत
A
5 5
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) In-class member initializer sets x=5. Output: 5.
व्याख्या (हिन्दी) इन-क्लास सदस्य इनिशियलाइज़र x=5 सेट करता है। आउटपुट: 5.
222
EN + हिं
GB What is the output: class A{int x; public: A(int v):x(v){} int get(){return x;}}; A a(10); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: A(int v):x(v){} int get(){return x;}}; ए ए(10); अदालत
A
10 10
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Constructor initializes x=10 via member initializer list. get() returns 10.
व्याख्या (हिन्दी) कंस्ट्रक्टर सदस्य इनिशियलाइज़र सूची के माध्यम से x=10 को इनिशियलाइज़ करता है। get() रिटर्न 10।
223
EN + हिं
GB What is 'this' pointer?
IN 'यह' सूचक क्या है?
A
Pointer to current object instance वर्तमान वस्तु उदाहरण के लिए सूचक
B
Pointer to base class बेस क्लास का सूचक
C
Global pointer वैश्विक सूचक
D
Pointer to member function सदस्य फ़ंक्शन के लिए सूचक
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 'this' is an implicit pointer available inside non-static member functions pointing to the current object.
व्याख्या (हिन्दी) 'यह' एक अंतर्निहित सूचक है जो गैर-स्थैतिक सदस्य फ़ंक्शंस के अंदर उपलब्ध है जो वर्तमान ऑब्जेक्ट की ओर इशारा करता है।
224
EN + हिं
GB What is the output: class A{public: static int x; int y;}; int A::x=5; A a; a.y=10; cout<
IN आउटपुट क्या है: वर्ग ए {सार्वजनिक: स्थिर int x; int y;}; int A::x=5; ए ए; a.y=10; अदालत
A
510 510
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A::x=5 (static, class-wide). a.y=10 (instance). Output: 510.
व्याख्या (हिन्दी) A::x=5 (स्थैतिक, वर्ग-व्यापी)। a.y=10 (उदाहरण). आउटपुट: 510.
225
EN + हिं
GB What is a 'friend function'?
IN 'मित्र फ़ंक्शन' क्या है?
A
Function with access to private/protected members निजी/संरक्षित सदस्यों तक पहुंच के साथ कार्य
B
A member function एक सदस्य समारोह
C
A virtual function एक आभासी कार्य
D
A static function एक स्थिर कार्य
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A friend function declared inside a class can access its private and protected members.
व्याख्या (हिन्दी) किसी क्लास के अंदर घोषित मित्र फ़ंक्शन अपने निजी और संरक्षित सदस्यों तक पहुंच सकता है।
211–225 of 1915