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
31
EN + हिं
GB What is the output: int a=5,b=10; int *p=&a; *p=*p+b; cout<
IN आउटपुट क्या है: int a=5,b=10; int *p=&a; *पी=*पी+बी; अदालत
A
15 15
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=5+10=15. Output: 15.
व्याख्या (हिन्दी) ए=5+10=15. आउटपुट: 15.
32
EN + हिं
GB What is the output: int *p=new int(10); auto sp=shared_ptr(p); auto sp2=shared_ptr(p); cout<
IN आउटपुट क्या है: int *p=new int(10); ऑटो एसपी=shared_ptr(p); ऑटो sp2=shared_ptr(p); अदालत
A
1 1
B
2 2
C
Undefined behavior अपरिभाषित व्यवहार
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Two separate shared_ptrs from same raw pointer: double-free UB when both try to delete.
व्याख्या (हिन्दी) एक ही रॉ पॉइंटर से दो अलग-अलग साझा_पीटीआर: जब दोनों हटाने का प्रयास करते हैं तो डबल-फ्री यूबी।
33
EN + हिं
GB 'What is the output: int a[]={1,2,3}; int *p=a+1; cout<<*( (1, 6, 77, 7, 4, 'What is the output: int x=5; int *p=&x; int **pp=&p; **pp=20; cout<
IN 'आउटपुट क्या है: int a[]={1,2,3}; int *p=a+1; अदालत
A
30}; int *p=&a[2]; cout<<*p<<*(p-1)<<*(p-2);', 'Pointer from end: *p 30}; int *p=&a[2]; अदालत
B
*(p-2)?', '302010', '302010', '102030', '102030', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', '*p=30 *(पी-2)?', '302010', '302010', '102030', '102030', 'संकलन त्रुटि', 'संकलन त्रुटि', 'अपरिभाषित', 'अपरिभाषित', शून्य, 'विकल्प_ए', '*पी=30
C
*(p-2)=10. Output: 302010.', 0, '2026-05-25', '2026-05-25'), (1, 6, 77, 7, 4, 'What is the output: void f(int **p,int v){**p=v;} int x=0; int *px=&x; f(&px,42); cout<<x;', 'Pass pointer-to-pointer to function?', '42', '42', '0', '0', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', '**p=*px=x=42. Output: 42.', 0, '2026-05-25', '2026-05-25'), (1, 6, 77, 7, 4, 'What is the output: auto up=make_unique<int[]>(3); up[0]=1;up[1]=2;up[2]=3; cout<<up[0]+up[2];', 'unique_ptr array sum?', '4', '4', '6', '6', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', '1+3=4. Output: 4.', 0, '2026-05-25', '2026-05-25'), (1, 6, 77, 7, 4, 'What is the output: int x=10; auto sp=make_shared<int>(x); cout<<sp.use_count()<<*sp;', 'shared_ptr basic?', '110', '110', '101', '101', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', 'use_count=1 *(पी-2)=10. आउटपुट: 302010.', 0, '2026-05-25', '2026-05-25'), (1, 6, 77, 7, 4, 'आउटपुट क्या है: void f(int **p,int v){**p=v;} int x=0; int *px=&x; f(&px,42); cout
D
2 2
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Null check before deref?
व्याख्या (हिन्दी) डेरेफ़ से पहले शून्य जाँच?
34
EN + हिं
GB What is the output: int x=5; int *p=&x; int **pp=&p; **pp=20; cout<
IN आउटपुट क्या है: int x=5; int *p=&x; int **pp=&p; **पीपी=20; अदालत
A
20 20
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) **pp=*p=x=20. Output: 20.
व्याख्या (हिन्दी) **पीपी=*पी=एक्स=20. आउटपुट: 20.
35
EN + हिं
GB What is the output: int a[]={10,20,30}; int *p=&a[2]; cout<<*p<<*(p-1)<<*(p-2);
IN आउटपुट क्या है: int a[]={10,20,30}; int *p=&a[2]; अदालत
A
302010 302010
B
102030 102030
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p=30,*(p-1)=20,*(p-2)=10. Output: 302010.
व्याख्या (हिन्दी) *पी=30,*(पी-1)=20,*(पी-2)=10. आउटपुट: 302010.
36
EN + हिं
GB What is the output: void f(int **p,int v){**p=v;} int x=0; int *px=&x; f(&px,42); cout<
IN आउटपुट क्या है: void f(int **p,int v){**p=v;} int x=0; int *px=&x; f(&px,42); अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) **p=*px=x=42. Output: 42.
व्याख्या (हिन्दी) **p=*px=x=42. आउटपुट: 42.
37
EN + हिं
GB What is the output: auto up=make_unique(3); up[0]=1;up[1]=2;up[2]=3; cout<
IN आउटपुट क्या है: auto up=make_unique(3); ऊपर[0]=1;ऊपर[1]=2;ऊपर[2]=3; अदालत
A
4 4
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+3=4. Output: 4.
व्याख्या (हिन्दी) 1+3=4. आउटपुट: 4.
38
EN + हिं
GB What is the output: int x=10; auto sp=make_shared(x); cout<
IN आउटपुट क्या है: int x=10; ऑटो एसपी=make_shared(x); अदालत
A
110 110
B
101 101
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) use_count=1, *sp=10. Output: 110.
व्याख्या (हिन्दी) उपयोग_गिनती=1, *एसपी=10. आउटपुट: 110.
39
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *p=a; cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *p=a; अदालत
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p[3]=*(p+3)=a[3]=4. Output: 4.
व्याख्या (हिन्दी) पी[3]=*(पी+3)=ए[3]=4. आउटपुट: 4.
40
EN + हिं
GB What is the output: int *p=nullptr; if(p) cout<<*p; else cout<<'N';
IN आउटपुट क्या है: int *p=nullptr; यदि (पी) कोउट
A
N एन
B
Undefined अपरिभाषित
C
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p is null; if(p) false; else prints N. Output: N.
व्याख्या (हिन्दी) पी शून्य है; यदि (पी) गलत; अन्यथा एन प्रिंट करता है। आउटपुट: एन।
41
EN + हिं
GB What is the output: int a[5]={1,2,3,4,5}; cout<<*(a+0)+*(a+1)+*(a+2)+*(a+3)+*(a+4);
IN आउटपुट क्या है: int a[5]={1,2,3,4,5}; अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 1+2+3+4+5=15. आउटपुट: 15.
42
EN + हिं
GB What is the output: int x=5; const int* const p=&x; cout<<*p;
IN आउटपुट क्या है: int x=5; स्थिरांक int* स्थिरांक p=&x; अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Can read; can't modify *p or p. *p=5. Output: 5.
व्याख्या (हिन्दी) पढ़ सकते हैं; *p या p को संशोधित नहीं कर सकते. *पी=5. आउटपुट: 5.
43
EN + हिं
GB What is the output: char str[]="hello"; char *p=str+4; cout<<*p;
IN आउटपुट क्या है: char str[]='हैलो'; चार *p=str+4; अदालत
A
o हे
B
h एच
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) str[4]='o'. Output: o.
व्याख्या (हिन्दी) str[4]='o'. आउटपुट: ओ.
44
EN + हिं
GB What is the output: int a[]={1,2,3}; int *p=a; p+=2; cout<<*p;
IN आउटपुट क्या है: int a[]={1,2,3}; int *p=a; पी+=2; अदालत
A
3 3
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p=a+2=&a[2]=3. Output: 3.
व्याख्या (हिन्दी) p=a+2=&a[2]=3. आउटपुट: 3.
45
EN + हिं
GB What is the output: int x=5; auto wp=weak_ptr{}; cout<
IN आउटपुट क्या है: int x=5; ऑटो wp=weak_ptr{}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default weak_ptr has no object; expired()=true=1. Output: 1.
व्याख्या (हिन्दी) डिफ़ॉल्ट कमजोर_पीटीआर में कोई वस्तु नहीं है; समाप्त()=सत्य=1. आउटपुट: 1.
31–45 of 127