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
91
EN + हिं
92
EN + हिं
GB What is the output: template auto sumTuple(tuplet){return apply([](auto...xs){return (xs+...);},t);} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो sumTuple(tuplet){return apply([](auto...xs){return (xs+...);},t);} cout
A
15 15
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
5 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 1+2+3+4+5=15. आउटपुट: 15.
93
EN + हिं
GB What is the output: class Cache{mapm; functionf; public:Cache(functionfn):f(fn){} int get(int x){if(!m.count(x))m[x]=f(x);return m[x];}}; Cache sq([](int x){return x*x;}); cout<
IN आउटपुट क्या है: class Cache{mapm; फ़ंक्शनएफ; public:Cache(functionfn):f(fn){} int get(int x){if(!m.count(x))m[x]=f(x);return m[x];}}; कैश sq([](int x){रिटर्न x*x;}); अदालत
A
25259 25259
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
25 25 9 25 25 9
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(5)=25 (computed); sq(5)=25 (cached); sq(3)=9. Output: 25259.
व्याख्या (हिन्दी) वर्ग(5)=25 (गणना); वर्ग(5)=25 (कैश्ड); वर्ग(3)=9. आउटपुट: 25259.
94
EN + हिं
GB What is the output: class A{public:virtual int eval()const=0;}; class Const:public A{int v;public:Const(int x):v(x){} int eval()const override{return v;}}; class Mul:public A{A *l,*r;public:Mul(A*a,A*b):l(a),r(b){} int eval()const override{return l->eval()*r->eval();}}; A*e=new Mul(new Const(3),new Mul(new Const(4),new Const(5))); cout<eval();
IN आउटपुट क्या है: class A{public:virtual int eval()const=0;}; वर्ग स्थिरांक:सार्वजनिक A{int v;सार्वजनिक:Const(int x):v(x){} int eval()const ओवरराइड{रिटर्न v;}}; क्लास मुल:पब्लिक ए{ए *एल,*आर;पब्लिक:मुल(ए*ए,ए*बी):एल(ए),आर(बी){} int eval()const ओवरराइड{रिटर्न l->eval()*r->eval();}}; ए*ई=नया मूल(नया स्थिरांक(3),नया मूल(नया स्थिरांक(4),नया स्थिरांक(5))); अदालत
A
60 60
B
20 20
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4*5=20; 3*20=60. Output: 60.
व्याख्या (हिन्दी) 4*5=20; 3*20=60. आउटपुट: 60.
95
EN + हिं
GB What is the output: template auto zip_with(vectora,vectorb,functionf){vectorr;for(int i=0;i({1,2,3},{4,5,6},[](int a,int b){return a*b;}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो zip_with(vectora,vectorb,functionf){vectorr;for(int i=0;i)
A
10 10
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) r[1]=2*5=10. Output: 10.
व्याख्या (हिन्दी) आर[1]=2*5=10. आउटपुट: 10.
96
EN + हिं
GB What is the output: class Protocol{public:virtual void send(string)=0; virtual string recv()=0;}; class Echo:public Protocol{string last; public:void send(string s)override{last=s;} string recv()override{return last;}}; Echo e; e.send("hello"); cout<
IN आउटपुट क्या है: क्लास प्रोटोकॉल{पब्लिक:वर्चुअल वॉयड सेंड(स्ट्रिंग)=0; वर्चुअल स्ट्रिंग recv()=0;}; कक्षा इको: सार्वजनिक प्रोटोकॉल {स्ट्रिंग अंतिम; सार्वजनिक:शून्य भेजें(स्ट्रिंग s)ओवरराइड{अंतिम=s;} स्ट्रिंग recv()ओवरराइड{अंतिम वापसी;}}; इको ई; ई.भेजें('हैलो'); अदालत
A
hello नमस्ते
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) recv returns last sent. Output: hello.
व्याख्या (हिन्दी) recv रिटर्न अंतिम बार भेजा गया। आउटपुट: नमस्ते.
97
EN + हिं
GB What is the output: template auto pipeline(T x){return x;} template auto pipeline(T x,F f,Fs...fs){return pipeline(f(x),fs...);} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो पाइपलाइन(T x){रिटर्न x;} टेम्पलेट ऑटो पाइपलाइन(T x,F f,Fs...fs){रिटर्न पाइपलाइन(f(x),fs...);} cout
A
169 169
B
100 100
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+3=13; 13^2=169. Output: 169.
व्याख्या (हिन्दी) 5*2=10; 10+3=13; 13^2=169. आउटपुट: 169.
98
EN + हिं
GB What is the output: class A{public:virtual int f()const=0; int g()const{return f()*f()+f();}}; class B:public A{public:int f()const override{return 3;}}; B b; cout<
IN आउटपुट क्या है: class A{public:virtual int f()const=0; int g()const{return f()*f()+f();}}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: int f() स्थिरांक ओवरराइड {वापसी 3;}}; बी बी; अदालत
A
12 12
B
9 9
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3*3+3=12. Output: 12.
व्याख्या (हिन्दी) 3*3+3=12. आउटपुट: 12.
99
EN + हिं
GB What is the output: class I{public:virtual void exec()=0; virtual ~I()=default;}; class Greet:public I{string n;public:Greet(string s):n(s){} void exec()override{cout<<"Hi "+n;}}; queue>q; q.push(make_unique("A")); q.push(make_unique("B")); while(!q.empty()){q.front()->exec();q.pop();}
IN आउटपुट क्या है: क्लास I{public:virtual void exec()=0; आभासी ~I()=डिफ़ॉल्ट;}; क्लास ग्रीट:पब्लिक I{स्ट्रिंग n;पब्लिक:ग्रीट(स्ट्रिंग s):n(s){} void exec()ओवरराइड{cout
A
Hi AHi B हाय एहाय बी
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Hi A Hi B हाय ए हाय बी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) FIFO: Hi A then Hi B. Output: Hi AHi B.
व्याख्या (हिन्दी) फीफो: हाय ए, फिर हाय बी। आउटपुट: हाय ए, हाय बी।
100
EN + हिं
GB What is the output: template class Lazy2{mutable optionalcache; functionfn; public:Lazy2(functionf):fn(f){} T get()const{if(!cache)cache=fn();return *cache;}}; int c=0; Lazy2l([&c](){return ++c;}); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Lazy2{म्यूटेबल ऑप्शनल कैश; functionfn; सार्वजनिक:Lazy2(functionf):fn(f){} T get()const{if(!cache)cache=fn();return *cache;}}; पूर्णांक सी=0; Lazy2l([&c](){रिटर्न++c;}); अदालत
A
111 111
B
121 121
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First get(): c=1,cache=1. Second: from cache=1. c=1. Output: 111.
व्याख्या (हिन्दी) सबसे पहले प्राप्त करें(): c=1,cache=1. दूसरा: कैश से=1. सी=1. आउटपुट: 111.
101
EN + हिं
GB What is the output: template auto transform_pair(pairp,functionf,functiong){return make_pair(f(p.first),g(p.second));} auto r=transform_pair({5,"hi"},[](int x){return x*2;},[](string s){return s+"!";}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ट्रांसफॉर्म_पेयर(पेयरप,फंक्शनएफ,फंक्शनजी){रिटर्न मेक_पेयर(एफ(पी.फर्स्ट),जी(पी.सेकेंड));} ऑटो आर=ट्रांसफॉर्म_पेयर({5,"हाय"},[](इंट एक्स){रिटर्न x*2;},[](स्ट्रिंग एस){रिटर्न एस+"!";}); अदालत
A
10hi! 10हाय!
B
5hi 5हाय
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; "hi"+"!"="hi!". Output: 10hi!.
व्याख्या (हिन्दी) 5*2=10; "हाय"+"!"="हाय!"। आउटपुट: 10हाय!
91–101 of 101