OOP Using C++ — MCQ Practice

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

📚 131 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
131 questions
106
EN + हिं
GB What is the output: template T dotProduct(vectora,vectorb){return inner_product(a.begin(),a.end(),b.begin(),T{});} cout<({1,2,3},{4,5,6});
IN आउटपुट क्या है: टेम्पलेट T dotProduct(vectora,vectorb){return inside_product(a.begin(),a.end(),b.begin(),T{});} cout
A
32 32
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*4+2*5+3*6=32. Output: 32.
व्याख्या (हिन्दी) 1*4+2*5+3*6=32. आउटपुट: 32.
107
EN + हिं
GB What is the output: template class Pair2{T first,second; public:Pair2(T a,T b):first(a),second(b){} T min_()const{return firstsecond?first:second;}}; Pair2p(3,7); cout<
IN आउटपुट क्या है: टेम्पलेट वर्ग Pair2{T प्रथम, द्वितीय; सार्वजनिक:जोड़ी2(टी ए,टी बी):पहला(ए),दूसरा(बी){} टी मिनट_() स्थिरांक{पहले लौटाएंदूसरा?पहला:दूसरा;}}; जोड़ी2पी(3,7); अदालत
A
37 37
B
73 73
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min=3,max=7. Output: 37.
व्याख्या (हिन्दी) न्यूनतम=3,अधिकतम=7. आउटपुट: 37.
108
EN + हिं
GB What is the output: template struct TypeSize{static constexpr int v=sizeof(T);}; cout<::v<::v<::v;
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर टाइपसाइज़{static constexpr int v=sizeof(T);}; अदालत
A
481 481
B
841 841
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int=4, double=8, char=1. Output: 481.
व्याख्या (हिन्दी) int=4, डबल=8, char=1. आउटपुट: 481.
109
EN + हिं
GB What is the output: template T zipAdd(vectora,vectorb){T s=T{};for(int i=0;i({1,2,3},{10,20,30});
IN आउटपुट क्या है: टेम्पलेट T zipAdd(vectora,vectorb){T s=T{};for(int i=0;i
A
140 140
B
60 60
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*10+2*20+3*30=10+40+90=140. Output: 140.
व्याख्या (हिन्दी) 1*10+2*20+3*30=10+40+90=140. आउटपुट: 140.
110
EN + हिं
GB What is the output: template T myMax2(T a,T b,Comp comp){return comp(a,b)?b:a;} cout<
IN आउटपुट क्या है: टेम्पलेट T myMax2(T a,T b,Comp COMP){रिटर्न COMP(a,b)?b:a;} cout
A
7 7
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) comp(3,7)=3<7=true: return b=7. Output: 7.
व्याख्या (हिन्दी) COMP(3,7)=3
111
EN + हिं
GB What is the output: template struct Lit{static constexpr auto value=V;}; cout<::value<::value;
IN आउटपुट क्या है: टेम्पलेट struct Lit{static constexpr auto value=V;}; अदालत
A
423.14 423.14
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
42 3 42 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42 and 3.14. Output: 423.14.
व्याख्या (हिन्दी) 42 और 3.14. आउटपुट: 423.14.
112
EN + हिं
GB What is the output: template T reduce2(vectorv,T init,functionf){return accumulate(v.begin(),v.end(),init,f);} cout<({1,2,3,4,5},0,[](int a,int b){return a+b;});
IN आउटपुट क्या है: टेम्पलेट T कम2(वेक्टरv,T init,functionf){रिटर्न एक्युमेटेड(v.begin(),v.end(),init,f);} cout
A
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
113
EN + हिं
GB What is the output: template class Stack2{vectors; public:void push(T x){s.push_back(x);} T pop(){T x=s.back();s.pop_back();return x;} T top()const{return s.back();} bool empty()const{return s.empty();}}; Stack2st; st.push(1);st.push(2);st.push(3); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Stack2{वेक्टर; सार्वजनिक:शून्य पुश(टी x){s.push_back(x);} T पॉप(){T x=s.back();s.pop_back();रिटर्न x;} T टॉप()const{रिटर्न s.बैक();} बूल खाली()const{रिटर्न s.empty();}}; स्टैक2st; st.push(1);st.push(2);st.push(3); अदालत
A
32 32
B
23 23
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) pop=3; top=2. Output: 32.
व्याख्या (हिन्दी) पॉप=3; शीर्ष=2. आउटपुट: 32.
114
EN + हिं
GB What is the output: template bool isPalin(const vector&v){return equal(v.begin(),v.begin()+v.size()/2,v.rbegin());} cout<{1,2,3,2,1})<{1,2,3});
IN आउटपुट क्या है: टेम्प्लेट बूल isPalin(const वेक्टर&v){रिटर्न इक्वल(v.begin(),v.begin()+v.size()/2,v.rbegin());} cout
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) First=palindrome=1; second=not=0. Output: 10.
व्याख्या (हिन्दी) प्रथम=पैलिंड्रोम=1; दूसरा=नहीं=0. आउटपुट: 10.
115
EN + हिं
GB What is the output: template struct Pow2{static const int v=2*Pow2::v;}; template<> struct Pow2<0>{static const int v=1;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट struct Pow2{static const int v=2*Pow2::v;}; टेम्पलेट संरचना Pow2{static const int v=1;}; अदालत
A
1024 1024
B
512 512
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2^10=1024. Output: 1024.
व्याख्या (हिन्दी) 2^10=1024. आउटपुट: 1024.
116
EN + हिं
GB What is the output: template T accumulate2(T* begin,T* end,T init){while(begin!=end)init+=*begin++;return init;} int a[]={1,2,3,4,5}; cout<
IN What is the output: template T accumulate2(T* begin,T* end,T init){while(begin!=end)init+=*begin++;return init;} int a[]={1,2,3,4,5}; अदालत
A
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
117
EN + हिं
GB What is the output: template class Maybe{optionalv; public:Maybe():v{}{} Maybe(T x):v(x){} template auto bind(F f)->Maybe{if(!v)return {};return {f(*v)};} T orElse(T d)const{return v.value_or(d);}}; Maybem(5); auto r=m.bind([](int x){return x*2;}).bind([](int x){return x+1;}); cout<
IN What is the output: template class Maybe{optionalv; सार्वजनिक:हो सकता है():v{} शायद(T x):v(x){} टेम्पलेट ऑटो बाइंड(F f)->शायद{if(!v)रिटर्न {};रिटर्न {f(*v)};} T या अन्यथा(T d)const{रिटर्न v.value_or(d);}}; मेबेम(5); auto r=m.bind([](int x){return x*2;}).bind([](int x){return x+1;}); अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5*2=10; 10+1=11. Output: 11.
व्याख्या (हिन्दी) 5*2=10; 10+1=11. आउटपुट: 11.
118
EN + हिं
GB What is the output: template T fromStr(const string& s); template<> int fromStr(const string& s){return stoi(s);} template<> double fromStr(const string& s){return stod(s);} cout<("42")+fromStr("3.5");
IN आउटपुट क्या है: टेम्पलेट T fromStr(const string& s); टेम्पलेट int fromStr(const string& s){return Stoi(s);} टेम्पलेट डबल fromStr(const string& s){return Stod(s);} cout
A
45.5 45.5
B
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42+3.5=45.5. Output: 45.5.
व्याख्या (हिन्दी) 42+3.5=45.5. आउटपुट: 45.5.
119
EN + हिं
GB What is the output: template auto groupBy(vectorv,functionf)->map>{map>m;for(T x:v)m[f(x)].push_back(x);return m;} auto g=groupBy({1,2,3,4,5,6},[](int x){return x%3;}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ग्रुपबी(वेक्टरवी,फंक्शनएफ)->मैप{मैपम;फॉर(टी एक्स:वी)एम[एफ(एक्स)].पुश_बैक(एक्स);रिटर्न एम;} ऑटो जी=ग्रुपबी({1,2,3,4,5,6},[](इंट एक्स){रिटर्न x%3;}); अदालत
A
222 222
B
321 321
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0:{3,6}=2; 1:{1,4}=2; 2:{2,5}=2. Output: 222.
व्याख्या (हिन्दी) 0:{3,6}=2; 1:{1,4}=2; 2:{2,5}=2. आउटपुट: 222.
120
EN + हिं
GB What is the output: template struct Reverse{using type=T;}; template struct Reverse>{using rest=typename Reverse>::type; using type=decltype(tuple_cat(declval(),declval>()));}; cout<>::type,tuple>;
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर रिवर्स {उपयोग प्रकार = टी;}; टेम्प्लेट संरचना रिवर्स {बाकी का उपयोग करके = टाइपनाम रिवर्स::टाइप; type=decltype(tuple_cat(declval(),declval()));} का उपयोग करना; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Reversed tuple=tuple. is_same=1. Output: 1.
व्याख्या (हिन्दी) उलटा टुपल = टुपल। समान=1 है. आउटपुट: 1.
106–120 of 131