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
1651
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 है।
1652
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।
1653
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.
1654
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.
1655
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.
1656
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.
1657
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.
1658
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.
1659
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.
1660
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 अस्थायी बनाता है; कथन समाप्ति के बाद संदर्भित अस्थायी अद्वितीय_पीटीआर: यूबी के लिए बाध्यकारी रेफरी। आउटपुट: यूबी.
1661
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.
1662
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 अप्रारंभीकृत होता है। यूबी.
1663
EN + हिं
GB What is the output: int a[]={5,4,3,2,1}; auto f=[](int *b,int *e){while(b
IN आउटपुट क्या है: int a[]={5,4,3,2,1}; ऑटो f=[](int *b,int *e){जबकि(b
A
54321 54321
B
12345 12345
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Prints 5,4,3,2,1. Output: 54321.
व्याख्या (हिन्दी) 5,4,3,2,1 प्रिंट करता है। आउटपुट: 54321.
1664
EN + हिं
GB What is the output: int x=42; auto wp=weak_ptr{}; {auto sp=make_shared(x); wp=sp; cout<<*wp.lock()<<' ';} cout<
IN आउटपुट क्या है: int x=42; ऑटो wp=weak_ptr{}; {ऑटो एसपी=मेक_शेयर्ड(x); wp=sp; अदालत
A
42 1 42 1
B
42 0 42 0
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Inside block: lock=42. After block: expired=1. Output: 42 1.
व्याख्या (हिन्दी) अंदर का ब्लॉक: लॉक=42. ब्लॉक के बाद: समाप्त=1. आउटपुट: 42 1.
1665
EN + हिं
GB What is the output: int a[3]={1,2,3}; int *p=a+3; cout<<(p==end(a));
IN आउटपुट क्या है: int a[3]={1,2,3}; int *p=a+3; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a+3==end(a)=true=1. Output: 1.
व्याख्या (हिन्दी) ए+3==अंत(ए)=सत्य=1. आउटपुट: 1.
1651–1665 of 1915