OOP Using C++ — MCQ Practice

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

📚 101 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
101 questions
31
EN + हिं
GB What is the output: class A{public:virtual int f()=0; int g(){return f()*2;}}; class B:public A{public:int f(){return 5;}}; B b; cout<
IN आउटपुट क्या है: class A{public:virtual int f()=0; int g(){रिटर्न f()*2;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f(){वापसी 5;}}; बी बी; अदालत
A
10 10
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B::f()=5; g()=5*2=10. Output: 10.
व्याख्या (हिन्दी) बी::एफ()=5; जी()=5*2=10. आउटपुट: 10.
32
EN + हिं
GB What is the output: template T cube(T x){return x*x*x;} cout<
IN आउटपुट क्या है: टेम्पलेट टी क्यूब(टी एक्स){रिटर्न x*x*x;} कॉउट
A
278.0 278.0
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
27 8 27 8
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) cube(3)=27, cube(2.0)=8.0. Output: 278.
व्याख्या (हिन्दी) घन(3)=27, घन(2.0)=8.0. आउटपुट: 278.
33
EN + हिं
GB What is the output: class Stack{vectorv; public: void push(int x){v.push_back(x);} int top(){return v.back();} int size(){return v.size();}}; Stack s; s.push(1);s.push(2);s.push(3); cout<
IN आउटपुट क्या है: class Stack{vectorv; सार्वजनिक: शून्य पुश (int x) {v.push_back (x);} int टॉप() {रिटर्न v.back();} int आकार() {रिटर्न v.size();}}; ढेर एस; एस.पुश(1);एस.पुश(2);एस.पुश(3); अदालत
A
33 33
B
13 13
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) top=3, size=3. Output: 33.
व्याख्या (हिन्दी) शीर्ष=3, आकार=3. आउटपुट: 33.
34
EN + हिं
GB What is the output: class A{public:virtual void f()=0;}; class B:public A{public:void f()override{cout<<'B';}}; function fn=[]{B().f();}; fn();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल वॉयड f()=0;}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: शून्य एफ() ओवरराइड {काउट
A
B बी
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B().f()=B. Output: B.
व्याख्या (हिन्दी) बी().एफ()=बी. आउटपुट: बी.
35
EN + हिं
GB What is the output: auto add=[](int a,int b){return a+b;}; auto mul=[](int a,int b){return a*b;}; auto apply=[](auto f,int a,int b){return f(a,b);}; cout<
IN आउटपुट क्या है: auto add=[](int a,int b){return a+b;}; ऑटो mul=[](int a,int b){return a*b;}; स्वत: लागू=[](ऑटो एफ,इंट ए,इंट बी){रिटर्न एफ(ए,बी);}; अदालत
A
712 712
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
7 12 7 12
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) apply(add,3,4)=7; apply(mul,3,4)=12. Output: 712.
व्याख्या (हिन्दी) लागू करें(जोड़ें,3,4)=7; लागू करें(mul,3,4)=12। आउटपुट: 712.
36
EN + हिं
GB What is the output: class Queue{dequed; public: void enq(int x){d.push_back(x);} int deq(){int x=d.front();d.pop_front();return x;} int size(){return d.size();}}; Queue q; q.enq(1);q.enq(2);q.enq(3); cout<
IN आउटपुट क्या है: class Queue{dequed; सार्वजनिक: void enq(int x){d.push_back(x);} int deq(){int x=d.front();d.pop_front();return x;} int size(){return d.size();}}; कतार क्यू; q.enq(1);q.enq(2);q.enq(3); अदालत
A
12 12
B
32 32
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) deq()=1; remaining size=2. Output: 12.
व्याख्या (हिन्दी) डेक()=1; शेष आकार=2. आउटपुट: 12.
37
EN + हिं
GB What is the output: class A{public:virtual double compute(double x)=0;}; class Square:public A{public:double compute(double x)override{return x*x;}}; class Cube:public A{public:double compute(double x)override{return x*x*x;}}; vector ops={new Square,new Cube}; for(auto p:ops) cout<compute(3)<<' ';
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल डबल कंप्यूट(डबल x)=0;}; वर्ग वर्ग:सार्वजनिक ए{सार्वजनिक:डबल कंप्यूट(डबल एक्स)ओवरराइड{रिटर्न x*x;}}; क्लास क्यूब: सार्वजनिक ए {सार्वजनिक: डबल कंप्यूट (डबल एक्स) ओवरराइड {रिटर्न x*x*x;}}; वेक्टर ऑप्स = {नया वर्ग, नया घन}; for(ऑटो पी:ऑप्स) कॉउट
A
9 27 9 27
B
3 9 3 9
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Square(3)=9, Cube(3)=27. Output: 9 27.
व्याख्या (हिन्दी) वर्ग(3)=9, घन(3)=27. आउटपुट: 9 27.
38
EN + हिं
GB What is the output: template class Box{T v; public: Box(T x):v(x){} T get()const{return v;}}; Box a(5); Box b("hi"); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास बॉक्स{T v; सार्वजनिक: Box(T x):v(x){} T get()const{return v;}}; बॉक्स ए(5); बॉक्स बी('हाय'); अदालत
A
5hi 5हाय
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
hi5 हाई 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.get()=5, b.get()=hi. Output: 5hi.
व्याख्या (हिन्दी) a.get()=5, b.get()=हाय। आउटपुट: 5हाय.
39
EN + हिं
GB What is the output: class Iter{int i=0,n; public: Iter(int n):n(n){} bool hasNext(){return i
IN आउटपुट क्या है: class Iter{int i=0,n; सार्वजनिक: Iter(int n):n(n){} bool hasNext(){return i
A
012 012
B
123 123
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Returns 0,1,2. Output: 012.
व्याख्या (हिन्दी) 0,1,2 लौटाता है। आउटपुट: 012.
40
EN + हिं
GB What is the output: struct Visitor{void operator()(int x){cout<<'I';} void operator()(string s){cout<<'S';}}; variant v=string("hi"); visit(Visitor{},v);
IN आउटपुट क्या है: struct विज़िटर{शून्य ऑपरेटर()(int x){cout
A
S एस
B
I मैं
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) v holds string; Visitor::operator()(string) called. Output: S.
व्याख्या (हिन्दी) v स्ट्रिंग रखता है; विज़िटर::ऑपरेटर()(स्ट्रिंग) को बुलाया गया। आउटपुट: एस.
41
EN + हिं
GB What is the output: class Logger{public:virtual void log(const string& m)=0;}; class ConsoleLogger:public Logger{public:void log(const string& m)override{cout<log("OK");
IN आउटपुट क्या है: क्लास लॉगर {सार्वजनिक: वर्चुअल शून्य लॉग (कॉन्स्ट स्ट्रिंग और एम) = 0;}; क्लास कंसोल लॉगर: सार्वजनिक लॉगर {सार्वजनिक: शून्य लॉग (कॉन्स्ट स्ट्रिंग और एम) ओवरराइड {काउट
A
OK ठीक है
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ConsoleLogger::log prints OK. Output: OK.
व्याख्या (हिन्दी) कंसोललॉगर::लॉग ठीक प्रिंट करता है। आउटपुट: ठीक है.
42
EN + हिं
GB What is the output: class A{public:virtual int f(int x)=0; int g(int x){return f(x)+f(x+1);}}; class B:public A{public:int f(int x)override{return x*x;}}; B b; cout<
IN आउटपुट क्या है: class A{public:virtual int f(int x)=0; int g(int x){रिटर्न f(x)+f(x+1);}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f(int x)ओवरराइड{रिटर्न x*x;}}; बी बी; अदालत
A
25 25
B
9 9
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 9+16=25. Output: 25.
व्याख्या (हिन्दी) 9+16=25. आउटपुट: 25.
43
EN + हिं
GB What is the output: class Event{public:virtual void handle()=0;}; class Click:public Event{public:void handle()override{cout<<"Click";}}; class Key:public Event{public:void handle()override{cout<<"Key";}}; vector events={new Click,new Key}; for(auto e:events) e->handle();
IN आउटपुट क्या है: क्लास इवेंट{पब्लिक:वर्चुअल वॉयड हैंडल()=0;}; क्लास क्लिक:सार्वजनिक इवेंट{सार्वजनिक:शून्य हैंडल()ओवरराइड{काउट
A
ClickKey क्लिककुंजी
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
KeyClick कुंजी क्लिक करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Click then Key. Output: ClickKey.
व्याख्या (हिन्दी) फिर कुंजी पर क्लिक करें। आउटपुट: क्लिककी.
44
EN + हिं
GB What is the output: template T identity(T x){return x;} cout<
IN आउटपुट क्या है: टेम्पलेट T पहचान(T x){रिटर्न x;} कोउट
A
5A3.14 5ए3.14
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
5 A 3 5 ए 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Returns each value. Output: 5A3.14.
व्याख्या (हिन्दी) प्रत्येक मान लौटाता है. आउटपुट: 5A3.14.
45
EN + हिं
GB What is the output: class Strategy{public:virtual int exec(int a,int b)=0;}; class Add:public Strategy{public:int exec(int a,int b){return a+b;}}; class Mul:public Strategy{public:int exec(int a,int b){return a*b;}}; Strategy*s=new Add; cout<exec(3,4); s=new Mul; cout<exec(3,4);
IN आउटपुट क्या है: class Strategy{public:virtual int exec(int a,int b)=0;}; कक्षा जोड़ें:सार्वजनिक रणनीति{सार्वजनिक:int exec(int a,int b){रिटर्न a+b;}}; क्लास मुल:सार्वजनिक रणनीति{सार्वजनिक:int exec(int a,int b){रिटर्न a*b;}}; रणनीति*s=नया जोड़ें; अदालत
A
712 712
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
7 12 7 12
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Add=7, Mul=12. Output: 712.
व्याख्या (हिन्दी) जोड़ें=7, मूल=12। आउटपुट: 712.
31–45 of 101