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
1771
EN + हिं
1772
EN + हिं
GB What is the output: class A{public:virtual ~A(){} virtual void f()=0;}; class B:public A{public:void f()override{cout<<'B';}}; class C:public A{public:void f()override{cout<<'C';}}; vectorv={new B,new C,new B,new C}; int n=0; for(auto p:v) {p->f(); if(dynamic_cast(p))n++;} cout<
IN आउटपुट क्या है: वर्ग A{सार्वजनिक:वर्चुअल ~A(){} वर्चुअल शून्य f()=0;}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: शून्य एफ() ओवरराइड {काउट
A
BCBC2 BCBC2
B
BCB2 बीसीबी2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B,C,B,C printed; 2 B's. Output: BCBC2.
व्याख्या (हिन्दी) बी,सी,बी,सी मुद्रित; 2 बी. आउटपुट: BCBC2.
1773
EN + हिं
GB What is the output: class A{public:virtual int f(){return 1;} virtual int g(){return f()+1;}}; class B:public A{public:int f()override{return 2;}}; B b; cout<
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एफ(){रिटर्न 1;} वर्चुअल इंट जी(){रिटर्न एफ()+1;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f()ओवरराइड{वापसी 2;}}; बी बी; अदालत
A
3 3
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.g()=A::g()=f()+1=B::f()+1=2+1=3. Output: 3.
व्याख्या (हिन्दी) b.g()=A::g()=f()+1=B::f()+1=2+1=3. आउटपुट: 3.
1774
EN + हिं
GB What is the output: class A{public:virtual void f()=0;}; struct B:A{void f()override{cout<<'B';}}; struct C:A{void f()override{cout<<'C';}}; auto apply=[](A& a){a.f();}; B b; C c; apply(b); apply(c);
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल वॉयड f()=0;}; संरचना बी:ए{शून्य एफ()ओवरराइड{काउट
A
BC ईसा पूर्व
B
CB सीबी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) apply(b)=B, apply(c)=C. Output: BC.
व्याख्या (हिन्दी) लागू करें (बी) = बी, लागू करें (सी) = सी। आउटपुट: बी.सी.
1775
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; A *arr[3]={new A,new B,new B}; for(auto p:arr)p->f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
122 122
B
111 111
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A=1,B=2,B=2. Output: 122.
व्याख्या (हिन्दी) ए=1,बी=2,बी=2. आउटपुट: 122.
1776
EN + हिं
GB What is the output: class A{public:virtual int f(){return 1;}}; class B:public A{public:int f()override{return 2;}}; int apply(A* p,int n){int s=0;for(int i=0;i
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एफ(){रिटर्न 1;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f()ओवरराइड{वापसी 2;}}; int लागू(A* p,int n){int s=0;for(int i=0;i
A
3 3
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) arr[i] accessed as A; all A::f()=1. Sum=3. Output: 3.
व्याख्या (हिन्दी) arr[i] को A के रूप में एक्सेस किया गया; सभी A::f()=1. योग=3. आउटपुट: 3.
1777
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';}}; class B:public A{public:void f()override{cout<<'B';}}; A* make(int t){return t?new B:new A;} for(int i=0;i<3;i++){auto*p=make(i%2);p->f();delete p;}
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
ABB एबीबी
B
ABA आबा
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) i=0:make(0)=A:A; i=1:make(1)=B:B; i=2:make(0)=A:A. Output: ABA.
व्याख्या (हिन्दी) i=0:make(0)=A:A; i=1:make(1)=B:B; i=2:make(0)=A:A. आउटपुट: एबीए.
1778
EN + हिं
1779
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';} virtual void g()=0;}; class B:public A{public:void f()override{cout<<'B';} void g()override{cout<<'G';}}; B b; b.f(); b.g();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
BG बीजी
B
AG एजी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f()=B; g()=G. Output: BG.
व्याख्या (हिन्दी) एफ()=बी; जी()=जी. आउटपुट: बीजी.
1780
EN + हिं
GB What is the output: class A{public:int x=0; virtual void inc(){x++;}}; class B:public A{public:void inc()override{x+=5;}}; vectorv={new A,new B,new A}; for(auto p:v)p->inc(); int s=0; for(auto p:v)s+=p->x; cout<
IN आउटपुट क्या है: class A{public:int x=0; आभासी शून्य इंक(){x++;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:शून्य इंक()ओवरराइड{x+=5;}}; वेक्टरv={नया ए,नया बी,नया ए}; for(auto p:v)p->inc(); int s=0; for(auto p:v)s+=p->x; अदालत
A
7 7
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A.x=1; B.x=5; A.x=1. Sum=7. Output: 7.
व्याख्या (हिन्दी) A.x=1; बी.एक्स=5; ए.एक्स=1. योग=7. आउटपुट: 7.
1781
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';} void g(){f();cout<<'G';}}; class B:public A{public:void f()override{cout<<'B';}}; B b; b.g();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
BG बीजी
B
AG एजी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f()=B::f()=B; then G. Output: BG.
व्याख्या (हिन्दी) f()=B::f()=B; फिर जी. आउटपुट: बीजी.
1782
EN + हिं
1783
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; A obj; B bobj; A* ptrs[]={&obj,&bobj,&obj}; for(A*p:ptrs)p->f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
121 121
B
111 111
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A=1,B=2,A=1. Output: 121.
व्याख्या (हिन्दी) ए=1,बी=2,ए=1. आउटपुट: 121.
1784
EN + हिं
GB What is the output: class A{public:virtual string name(){return "A";} string greet(){return "Hi "+name();}}; class B:public A{public:string name()override{return "B";}}; B b; cout<
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल स्ट्रिंग नेम(){रिटर्न "ए";} स्ट्रिंग ग्रीट(){रिटर्न "हाय "+नेम();}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:स्ट्रिंग नाम()ओवरराइड{वापसी "बी";}}; बी बी; अदालत
A
Hi B हाय बी
B
Hi A हाय ए
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) greet() calls virtual name(): B::name()=B. Output: Hi B.
व्याख्या (हिन्दी) greet() वर्चुअल नाम() को कॉल करता है: B::name()=B। आउटपुट: हाय बी.
1785
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<1;}}; class B:public A{public:void f()override{cout<<2;}}; functionfp=[](A*p){p->f();}; fp(new A); fp(new B);
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
12 12
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Virtual dispatch: 1,2. Output: 12.
व्याख्या (हिन्दी) आभासी प्रेषण: 1,2. आउटपुट: 12.
1771–1785 of 1915