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
91
EN + हिं
GB What is the output: int x=5,y=10,z=15; int *ptrs[]={&x,&y,&z}; int s=0; for(auto p:ptrs) s+=*p; cout<
IN आउटपुट क्या है: int x=5,y=10,z=15; int *ptrs[]={&x,&y,&z}; int s=0; for(auto p:ptrs) s+=*p; अदालत
A
30 30
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5+10+15=30. Output: 30.
व्याख्या (हिन्दी) 5+10+15=30. आउटपुट: 30.
92
EN + हिं
GB What is the output: int a[]={3,1,4,1,5}; nth_element(a,a+2,a+5); cout<
IN आउटपुट क्या है: int a[]={3,1,4,1,5}; nth_element(a,a+2,a+5); अदालत
A
3 3
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,1,3,4,5. 3rd=3. Output: 3.
व्याख्या (हिन्दी) क्रमबद्ध: 1,1,3,4,5. 3=3. आउटपुट: 3.
93
EN + हिं
GB What is the output: struct Node{int v; shared_ptr next;}; auto a=make_shared(Node{1,nullptr}); auto b=make_shared(Node{2,a}); cout<next->v;
IN What is the output: struct Node{int v; share_ptr अगला;}; auto a=make_shared(Node{1,nullptr}); auto b=make_shared(Node{2,a}); coutv;
A
1 1
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b->next=a; a->v=1. Output: 1.
व्याख्या (हिन्दी) बी->अगला=ए; a->v=1. आउटपुट: 1.
94
EN + हिं
GB What is the output: int a[]={1,2,3}; int *p=a; cout<<(*p++)<<(*p++);
IN आउटपुट क्या है: int a[]={1,2,3}; int *p=a; अदालत
A
12 12
B
23 23
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17: left-to-right evaluation of <<. First *p++=1(p=a+1); then *p++=2(p=a+2). Output: 12.
व्याख्या (हिन्दी) C++17: बाएँ से दाएँ मूल्यांकन
95
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *p=a+2,*q=a; cout<
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *p=a+2,*q=a; अदालत
A
21 21
B
23 23
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p-q=2. *(q+p-a-2)=*(a+2+a-a-2)=*(a+... wait: q=a,p=a+2. p-a=2. *(q+2-2)=*(a)=1. q+p-a-2=a+a+2-a-2=a. *a=1. Hmm: 21. But *(q+p-a-2): q=a(pointer), p=a+2(pointer). q+p would be adding two pointers = UB. Output: Undefined.
व्याख्या (हिन्दी) पी-क्यू=2. *(q+p-a-2)=*(a+2+a-a-2)=*(a+... रुकें: q=a,p=a+2. p-a=2. *(q+2-2)=*(a)=1. q+p-a-2=a+a+2-a-2=a. *a=1. हम्म: 21. लेकिन *(q+p-a-2): q=a(सूचक), p=a+2(सूचक)। q+p दो सूचक जोड़ देगा = यूबी।
96
EN + हिं
GB What is the output: int x=5; int *p=&x; auto f=[p]()->int{return *p*2;}; cout<
IN आउटपुट क्या है: int x=5; int *p=&x; ऑटो f=[p]()->int{रिटर्न *p*2;}; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p=5; 5*2=10. Output: 10.
व्याख्या (हिन्दी) *पी=5; 5*2=10. आउटपुट: 10.
97
EN + हिं
GB What is the output: int a[]={1,2,3}; cout<<(*(a+0)+*(a+1)+*(a+2));
IN आउटपुट क्या है: int a[]={1,2,3}; अदालत
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.
98
EN + हिं
GB What is the output: int x=5; int *p=&x; *p+=*p; cout<
IN आउटपुट क्या है: int x=5; int *p=&x; *पी+=*पी; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x+=x=10. Output: 10.
व्याख्या (हिन्दी) x+=x=10. आउटपुट: 10.
99
EN + हिं
GB What is the output: int a[]={10,20,30}; for(int *p=a;p
IN आउटपुट क्या है: int a[]={10,20,30}; for(int *p=a;p
A
40 40
B
20 20
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[1]=20*2=40. Output: 40.
व्याख्या (हिन्दी) ए[1]=20*2=40. आउटपुट: 40.
100
EN + हिं
GB What is the output: char s[]="hello"; for(char *p=s;*p;p++) if(*p=='l') *p='L'; cout<
IN आउटपुट क्या है: char s[]='हैलो'; for(char *p=s;*p;p++) if(*p=='l') *p='L'; अदालत
A
heLLo नमस्ते
B
hello नमस्ते
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Both l's replaced. Output: heLLo.
व्याख्या (हिन्दी) दोनों एल को बदल दिया गया। आउटपुट: हेलो.
101
EN + हिं
GB What is the output: int a[]={5,3,8,1,4}; int *mx=a; for(int *p=a+1;p*mx) mx=p; cout<<*mx<<(mx-a);
IN आउटपुट क्या है: int a[]={5,3,8,1,4}; int *mx=a; for(int *p=a+1;p*mx) mx=p; अदालत
A
82 82
B
58 58
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) max=8 at index 2. Output: 82.
व्याख्या (हिन्दी) सूचकांक 2 पर अधिकतम=8। आउटपुट: 82।
102
EN + हिं
GB What is the output: int x=5; const int* cp=&x; int* const pc=&x; *pc=10; cout<<*cp;
IN आउटपुट क्या है: int x=5; स्थिरांक int* cp=&x; int* const pc=&x; *पीसी=10; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *pc=10 changes x=10. cp reads x=10. Output: 10.
व्याख्या (हिन्दी) *पीसी=10 परिवर्तन x=10। सीपी x=10 पढ़ता है। आउटपुट: 10.
103
EN + हिं
GB What is the output: auto p=make_unique>(3,4); cout<first+p->second;
IN आउटपुट क्या है: auto p=make_unique(3,4); कॉउटसेकंड;
A
7 7
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+4=7. Output: 7.
व्याख्या (हिन्दी) 3+4=7. आउटपुट: 7.
104
EN + हिं
GB What is the output: int a[]={1,2,3,4,5}; int *p=a; while(*p++!=3) {} cout<<*p;
IN आउटपुट क्या है: int a[]={1,2,3,4,5}; int *p=a; while(*p++!=3) {} cout
A
4 4
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p++=1(p=a+1),2,3(p=a+3). Now *p=a[3]=4. Output: 4.
व्याख्या (हिन्दी) *p++=1(p=a+1),2,3(p=a+3). अब *p=a[3]=4. आउटपुट: 4.
105
EN + हिं
GB What is the output: int x=5; shared_ptr p=make_shared(); *p=x*2; cout<<*p;
IN आउटपुट क्या है: int x=5; share_ptr p=make_shared(); *पी=एक्स*2; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) *p=10. Output: 10.
व्याख्या (हिन्दी) *पी=10. आउटपुट: 10.
91–105 of 127