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
781
EN + हिं
GB What is the output: int a[3]={1,2,3}; auto f=[](int *p,int n){int s=0;for(int i=0;i
IN आउटपुट क्या है: int a[3]={1,2,3}; ऑटो f=[](int *p,int n){int s=0;for(int i=0;i
A
6 6
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3=6. Output: 6.
व्याख्या (हिन्दी) 1+2+3=6. आउटपुट: 6.
782
EN + हिं
GB What is the output: int *p=new int[5]; for(int i=0;i<5;i++) p[i]=i*i; cout<
IN आउटपुट क्या है: int *p=new int[5]; for(int i=0;i
A
9 9
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p[3]=9. Output: 9.
व्याख्या (हिन्दी) पी[3]=9. आउटपुट: 9.
783
EN + हिं
GB What is the output: int x=5; shared_ptr a,b; a=make_shared(x); b=a; a.reset(); cout<
IN आउटपुट क्या है: int x=5; साझा_पीटीआर ए,बी; a=make_shared(x); बी=ए; ए.रीसेट(); अदालत
A
15 15
B
05 05
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) After a.reset(): b owns the object. use_count=1, *b=5. Output: 15.
व्याख्या (हिन्दी) a.reset() के बाद: b ऑब्जेक्ट का स्वामी है। उपयोग_गिनती=1, *बी=5. आउटपुट: 15.
784
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *begin=a,*end=a+5; cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *शुरू=ए,*अंत=ए+5; अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
785
EN + हिं
GB What is the output: int x=10; auto* p=new auto(x); cout<<*p<<' '; delete p; cout<<(p=nullptr)==nullptr;
IN आउटपुट क्या है: int x=10; ऑटो* पी=नया ऑटो(x); अदालत
A
10 1 10 1
B
10 0 10 0
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p=10; delete; p=nullptr; nullptr==nullptr=1. Output: 10 1.
व्याख्या (हिन्दी) *पी=10; मिटाना; p=nullptr; nullptr==nullptr=1. आउटपुट: 10 1.
786
EN + हिं
GB What is the output: int x=5; int *p=&x; cout<(p)%4;
IN आउटपुट क्या है: int x=5; int *p=&x; अदालत
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Int is typically 4-byte aligned; address divisible by 4. Output: 0.
व्याख्या (हिन्दी) Int आमतौर पर 4-बाइट संरेखित होता है; पता 4 से विभाज्य है। आउटपुट: 0.
787
EN + हिं
GB What is the output: int a[]={1,2,3}; int *p=a; cout<
IN आउटपुट क्या है: int a[]={1,2,3}; int *p=a; अदालत
A
123 123
B
321 321
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p[0]=1,p[1]=2,p[2]=3. Output: 123.
व्याख्या (हिन्दी) पी[0]=1,पी[1]=2,पी[2]=3. आउटपुट: 123.
788
EN + हिं
GB What is the output: int x=10; int &r=x; int *p=&r; ++(*p); cout<
IN आउटपुट क्या है: int x=10; int &r=x; int *p=&r; ++(*p); अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) &r=&x. ++(*p)=++x=11. r=11. Output: 11.
व्याख्या (हिन्दी) &r=&x. ++(*p)=++x=11. आर=11. आउटपुट: 11.
789
EN + हिं
GB What is the output: int a[]={2,4,6,8}; int *p=a+1; cout<
IN आउटपुट क्या है: int a[]={2,4,6,8}; int *p=a+1; अदालत
A
246 246
B
468 468
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p[-1]=a[0]=2,p[0]=a[1]=4,p[1]=a[2]=6. Output: 246.
व्याख्या (हिन्दी) p[-1]=a[0]=2,p[0]=a[1]=4,p[1]=a[2]=6. आउटपुट: 246.
790
EN + हिं
GB What is the output: class A{public:int x=0; void f(){x++;}}; A a1,a2; a1.f();a1.f(); a2.f(); cout<
IN आउटपुट क्या है: class A{public:int x=0; शून्य f(){x++;}}; ए ए1,ए2; a1.f();a1.f(); a2.f(); अदालत
A
21 21
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a1.x=2, a2.x=1. Output: 21.
व्याख्या (हिन्दी) a1.x=2, a2.x=1. आउटपुट: 21.
791
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} int get()const{return x;} void set(int v){x=v;}}; A a(5); a.set(10); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} int get()const{return x;} void set(int v){x=v;}}; ए ए(5); ए.सेट(10); अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) set(10) changes x=10. get()=10. Output: 10.
व्याख्या (हिन्दी) सेट(10) x=10 बदलता है। प्राप्त करें()=10. आउटपुट: 10.
792
EN + हिं
GB What is 'rule of zero'?
IN 'शून्य का नियम' क्या है?
A
Don't define any special members; use smart pointers/containers किसी विशेष सदस्य को परिभाषित न करें; स्मार्ट पॉइंटर्स/कंटेनर्स का उपयोग करें
B
No constructors at all बिल्कुल कोई कंस्ट्रक्टर नहीं
C
Zero members class शून्य सदस्य वर्ग
D
Empty class खाली कक्षा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) If a class uses smart pointers and standard containers, compiler-generated specials work correctly; define none.
व्याख्या (हिन्दी) यदि कोई क्लास स्मार्ट पॉइंटर्स और मानक कंटेनरों का उपयोग करता है, तो कंपाइलर-जनरेटेड स्पेशल सही ढंग से काम करते हैं; किसी को परिभाषित न करें.
793
EN + हिं
GB What is the output: class A{public:static int n; A(){n++;} ~A(){n (1, 6, 78, 8, 4, 'What is the output: class A{int x=5; public: int f()const{return x;} void g(){x=10;}}; A a; cout<
IN आउटपुट क्या है: class A{public:static int n; A(){n++;} ~A(){n (1, 6, 78, 8, 4, 'आउटपुट क्या है: क्लास ए{int x=5; सार्वजनिक: int f()const{return x;} void g(){x=10;}}; A a; cout
A
Conv op: class->other type; constructor: other type->class रूपांतरण ऑप: वर्ग->अन्य प्रकार; कंस्ट्रक्टर: अन्य प्रकार->वर्ग
B
Same thing एक ही बात
C
Both are implicit दोनों अन्तर्निहित हैं
D
Neither is explicit कोई भी स्पष्ट नहीं है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) operator int() converts class to int; A(int) converts int to class.
व्याख्या (हिन्दी) ऑपरेटर int() क्लास को int में परिवर्तित करता है; A(int) int को क्लास में परिवर्तित करता है।
794
EN + हिं
GB What is the output: class A{int x=5; public: int f()const{return x;} void g(){x=10;}}; A a; cout<
IN आउटपुट क्या है: class A{int x=5; सार्वजनिक: int f()const{return x;} void g(){x=10;}}; ए ए; अदालत
A
510 510
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Initial f()=5; g() sets x=10; f()=10. Output: 510.
व्याख्या (हिन्दी) आरंभिक f()=5; g() x=10 सेट करता है; एफ()=10. आउटपुट: 510.
795
EN + हिं
GB What is 'conversion operator' vs constructor conversion?
IN 'रूपांतरण ऑपरेटर' बनाम कंस्ट्रक्टर रूपांतरण क्या है?
A
Conv op: class->other type; constructor: other type->class रूपांतरण ऑप: वर्ग->अन्य प्रकार; कंस्ट्रक्टर: अन्य प्रकार->वर्ग
B
Same thing एक ही बात
C
Both are implicit दोनों अन्तर्निहित हैं
D
Neither is explicit कोई भी स्पष्ट नहीं है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) operator int() converts class to int; A(int) converts int to class.
व्याख्या (हिन्दी) ऑपरेटर int() क्लास को int में परिवर्तित करता है; A(int) int को क्लास में परिवर्तित करता है।
781–795 of 1915