OOP Using C++ — MCQ Practice

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

📚 127 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
127 questions
106
EN + हिं
GB What is the output: int a[5]; int *p=a; for(int i=0;i<5;i++) *p++=i*i; cout<
IN आउटपुट क्या है: int a[5]; int *p=a; for(int i=0;i
A
9 9
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[3]=3^2=9. Output: 9.
व्याख्या (हिन्दी) a[3]=3^2=9. आउटपुट: 9.
107
EN + हिं
GB What is the output: string s="hello"; char *p=&s[0]; *(p+4)='!'; cout<
IN आउटपुट क्या है: स्ट्रिंग s='हैलो'; चार *p=&s[0]; *(पी+4)='!'; अदालत
A
hell! नरक!
B
hello नमस्ते
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) s[4]='!'. Output: hell!.
व्याख्या (हिन्दी) s[4]='!'. आउटपुट: नरक!
108
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *b=new int[5]; copy(a,a+5,b); transform(b,b+5,b,[](int x){return x*x;}); cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *b=new int[5]; कॉपी(ए,ए+5,बी); परिवर्तन(बी,बी+5,बी,[](int x){रिटर्न x*x;}); अदालत
A
9 9
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b[2]=3^2=9. Output: 9.
व्याख्या (हिन्दी) बी[2]=3^2=9. आउटपुट: 9.
109
EN + हिं
GB What is the output: int x=5,y=10; int *p=&x; swap(p,*(int**)&y);
IN आउटपुट क्या है: int x=5,y=10; int *p=&x; स्वैप(p,*(int**)&y);
A
Undefined behavior अपरिभाषित व्यवहार
B
5 5
C
Compile error संकलन त्रुटि
D
10 10
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Casting int* to int** and swapping is UB.
व्याख्या (हिन्दी) Int* को int** में कास्ट करना और स्वैप करना UB है।
110
EN + हिं
GB What is the output: int a[]={3,1,4,1,5}; sort(a,a+5); int *it=lower_bound(a,a+5,1); cout<<(it-a);
IN आउटपुट क्या है: int a[]={3,1,4,1,5}; क्रमबद्ध करें(ए,ए+5); पूर्णांक *यह=निचला_बाउंड(ए,ए+5,1); अदालत
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,1,3,4,5. First>=1 at index 0. Output: 0.
व्याख्या (हिन्दी) क्रमबद्ध: 1,1,3,4,5. सूचकांक 0 पर प्रथम>=1। आउटपुट: 0।
111
EN + हिं
GB What is the output: vector v={1,2,3}; auto p=v.data(); p[1]=10; cout<
IN आउटपुट क्या है: वेक्टर v={1,2,3}; ऑटो पी=v.डेटा(); पी[1]=10; अदालत
A
10 10
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) data() returns pointer to underlying array. p[1]=10 changes v[1]. Output: 10.
व्याख्या (हिन्दी) डेटा() अंतर्निहित सरणी में पॉइंटर लौटाता है। p[1]=10 परिवर्तन v[1]। आउटपुट: 10.
112
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; auto* p=ranges::max_element(a); cout<<*p;
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; ऑटो* पी=रेंज::मैक्स_एलिमेंट(ए); अदालत
A
5 5
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) max=5. Output: 5.
व्याख्या (हिन्दी) अधिकतम=5. आउटपुट: 5.
113
EN + हिं
GB What is the output: int x=0; auto inc=[&x]()noexcept{x++;}; for(int i=0;i<10;i++) inc(); cout<
IN आउटपुट क्या है: int x=0; ऑटो इंक=[&x]()noexcept{x++;}; for(int i=0;i
A
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Increments 10 times. Output: 10.
व्याख्या (हिन्दी) 10 गुना वृद्धि. आउटपुट: 10.
114
EN + हिं
GB What is the output: int a[]={1,2,3}; int (*p)[3]=&a; cout<<(*p)[0]+(*p)[2];
IN आउटपुट क्या है: int a[]={1,2,3}; int (*p)[3]=&a; अदालत
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (*p)[0]=1, (*p)[2]=3. 1+3=4. Output: 4.
व्याख्या (हिन्दी) (*पी)[0]=1, (*पी)[2]=3. 1+3=4. आउटपुट: 4.
115
EN + हिं
GB What is the output: int x=10; auto sp1=make_shared(x); auto sp2=sp1; *sp1=20; cout<<*sp2;
IN आउटपुट क्या है: int x=10; ऑटो sp1=make_shared(x); ऑटो sp2=sp1; *sp1=20; अदालत
A
20 20
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sp1 and sp2 share same object. *sp1=20 changes *sp2. Output: 20.
व्याख्या (हिन्दी) sp1 और sp2 एक ही वस्तु साझा करते हैं। *sp1=20 परिवर्तन *sp2. आउटपुट: 20.
116
EN + हिं
GB What is the output: void f(unique_ptrp){cout<<*p;} f(make_unique(99));
IN आउटपुट क्या है: void f(unique_ptrp){cout
A
99 99
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) make_unique moved into f. *p=99. Output: 99.
व्याख्या (हिन्दी) make_unique f में चला गया। *पी=99. आउटपुट: 99.
117
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; auto it=find(begin(a),end(a),4); *it*=10; cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; स्वतः यह=ढूंढें(शुरू(ए),अंत(ए),4); *यह*=10; अदालत
A
40 40
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4 at a[3]; *it=40. a[3]=40. Output: 40.
व्याख्या (हिन्दी) 4 पर एक[3]; *यह=40. ए[3]=40. आउटपुट: 40.
118
EN + हिं
GB What is the output: int x=5; auto& r=*make_unique(x); cout<
IN आउटपुट क्या है: int x=5; ऑटो& r=*make_unique(x); अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined behavior अपरिभाषित व्यवहार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) make_unique creates temporary; binding ref to dereferenced temporary unique_ptr: UB after statement end. Output: UB.
व्याख्या (हिन्दी) make_unique अस्थायी बनाता है; कथन समाप्ति के बाद संदर्भित अस्थायी अद्वितीय_पीटीआर: यूबी के लिए बाध्यकारी रेफरी। आउटपुट: यूबी.
119
EN + हिं
GB What is the output: int a[]={10,20,30}; int *p=a; cout<
IN आउटपुट क्या है: int a[]={10,20,30}; int *p=a; अदालत
A
202020 202020
B
103020 103020
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p[1]=*(p+1)=20; 1[p]=*(1+p)=20; *(1+p)=20. Output: 202020.
व्याख्या (हिन्दी) पी[1]=*(पी+1)=20; 1[पी]=*(1+पी)=20; *(1+पी)=20. आउटपुट: 202020.
120
EN + हिं
GB What is the output: int x=5; int *p=new int(*p);
IN आउटपुट क्या है: int x=5; int *p=नया int(*p);
A
Undefined behavior अपरिभाषित व्यवहार
B
5 5
C
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p is uninitialized when *p is evaluated. UB.
व्याख्या (हिन्दी) जब *p का मूल्यांकन किया जाता है तो p अप्रारंभीकृत होता है। यूबी.
106–120 of 127