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
61
EN + हिं
GB What is the output: template constexpr auto makeArray(){array a{}; for(size_t i=0;i(); cout<
IN आउटपुट क्या है: template constexpr auto makeArray(){array a{}; for(size_t i=0;i
A
9 9
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[3]=3*3=9. Output: 9.
व्याख्या (हिन्दी) ए[3]=3*3=9. आउटपुट: 9.
62
EN + हिं
GB What is the output: template class Optional{bool has=false; T v; public: void set(T x){has=true;v=x;} bool hasVal(){return has;} T get(){return v;}}; Optional o; cout<
IN आउटपुट क्या है: टेम्पलेट क्लास वैकल्पिक {बूल है = गलत; टी वी; सार्वजनिक: void set(T x){has=true;v=x;} bool hasVal(){return has;} T get(){return v;}}; वैकल्पिक ओ; अदालत
A
015 015
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
0 1 5 0 1 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Initial: 0. After set: 1, get=5. Output: 015.
व्याख्या (हिन्दी) आरंभिक: 0. सेट के बाद: 1, प्राप्त करें=5. आउटपुट: 015.
63
EN + हिं
GB What is the output: template int countIf(vector& v,Pred p){int n=0;for(auto x:v) if(p(x)) n++;return n;} vectorv={1,2,3,4,5}; cout<
IN आउटपुट क्या है: टेम्पलेट int countIf(वेक्टर& v,Pred p){int n=0;for(auto x:v) if(p(x)) n++;रिटर्न n;} वेक्टरv={1,2,3,4,5}; अदालत
A
2 2
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2 and 4 are even. count=2. Output: 2.
व्याख्या (हिन्दी) 2 और 4 सम हैं. गिनती=2. आउटपुट: 2.
64
EN + हिं
GB What is the output: template T lerp(T a,T b,double t){return a+(b-a)*t;} cout<
IN आउटपुट क्या है: टेम्पलेट T lerp(T a,T b,double t){return a+(b-a)*t;} cout
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+(10-0)*0.5=5. Output: 5.
व्याख्या (हिन्दी) 0+(10-0)*0.5=5. आउटपुट: 5.
65
EN + हिं
GB What is the output: template T gcd(T a,T b){return b?gcd(b,a%b):a;} cout<
IN आउटपुट क्या है: टेम्पलेट T gcd(T a,T b){return b?gcd(b,a%b):a;} cout
A
12 12
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(36,48)=GCD(48,36)=GCD(36,12)=GCD(12,0)=12. Output: 12.
व्याख्या (हिन्दी) जीसीडी(36,48)=जीसीडी(48,36)=जीसीडी(36,12)=जीसीडी(12,0)=12। आउटपुट: 12.
66
EN + हिं
GB What is the output: template vector filter(vector v,function p){vectorr;for(T x:v)if(p(x))r.push_back(x);return r;} auto r=filter({1,2,3,4,5},[](int x){return x>3;}); cout<
IN आउटपुट क्या है: टेम्पलेट वेक्टर फ़िल्टर(वेक्टर v,फ़ंक्शन p){vectorr;for(T x:v)if(p(x))r.push_back(x);return r;} auto r=filter({1,2,3,4,5},[](int x){return x>3;}); अदालत
A
2 2
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 4 and 5. size=2. Output: 2.
व्याख्या (हिन्दी) 4 और 5. आकार=2. आउटपुट: 2.
67
EN + हिं
GB What is the output: template T reduce(vector v,T init,function f){for(T x:v) init=f(init,x);return init;} cout<({1,2,3,4,5},0,[](int a,int b){return a+b;});
IN आउटपुट क्या है: टेम्पलेट T कम करें(वेक्टर v,T init,function f){for(T x:v) init=f(init,x);रिटर्न init;} cout
A
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
68
EN + हिं
GB What is the output: template T myMin(T a,T b){return a T myMin(T a,Rest...rest){return myMin(a,myMin(rest...));} cout<
IN आउटपुट क्या है: टेम्पलेट T myMin(T a,T b){return a
A
1 1
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min of all = 1. Output: 1.
व्याख्या (हिन्दी) सभी का न्यूनतम = 1. आउटपुट: 1.
69
EN + हिं
GB What is the output: template class Singleton{static T* inst; public: static T& get(){if(!inst) inst=new T; return *inst;} Singleton()=delete;}; template T* Singleton::inst=nullptr; struct Config{int x=42;}; cout<::get().x;
IN आउटपुट क्या है: टेम्प्लेट क्लास सिंगलटन {स्टेटिक टी * इंस्टा; सार्वजनिक: स्थिर T& get(){if(!inst) inst=new T; वापसी *इंस्ट;} सिंगलटन()=हटाएं;}; टेम्पलेट T* सिंगलटन::inst=nullptr; struct कॉन्फ़िग {int x=42;}; अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Config x=42. Output: 42.
व्याख्या (हिन्दी) कॉन्फ़िग x=42. आउटपुट: 42.
70
EN + हिं
GB What is the output: template constexpr int sumNT=(...+Ns); cout<;
IN आउटपुट क्या है: template constexpr int sumNT=(...+Ns); अदालत
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 1+2+3+4+5=15. आउटपुट: 15.
71
EN + हिं
GB What is the output: template class TypeList{}; cout<,TypeList>;
IN आउटपुट क्या है: टेम्पलेट क्लास टाइपलिस्ट{}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Same template with same arg: same type. is_same=1. Output: 1.
व्याख्या (हिन्दी) समान तर्क के साथ समान टेम्पलेट: समान प्रकार। समान=1 है. आउटपुट: 1.
72
EN + हिं
GB What is the output: template T constexprMax(T a,T b){return a>b?a:b;} constexpr int m=constexprMax(3,7); cout<
IN आउटपुट क्या है: टेम्पलेट T constexprMax(T a,T b){return a>b?a:b;} constexpr int m=constexprMax(3,7); अदालत
A
7 7
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexprMax(3,7)=7. Output: 7.
व्याख्या (हिन्दी) constexprMax(3,7)=7. आउटपुट: 7.
73
EN + हिं
GB What is the output: template struct IsIntegral{static const bool v=false;}; template<> struct IsIntegral{static const bool v=true;}; template<> struct IsIntegral{static const bool v=true;}; cout<::v<::v<::v;
IN आउटपुट क्या है: टेम्पलेट struct IsIntegral{static const bool v=false;}; टेम्पलेट संरचना IsIntegral{static const bool v=true;}; टेम्पलेट संरचना IsIntegral{static const bool v=true;}; अदालत
A
101 101
B
010 010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int=1, double=0, long=1. Output: 101.
व्याख्या (हिन्दी) int=1, दोगुना=0, लंबा=1। आउटपुट: 101.
74
EN + हिं
GB What is the output: template auto zip(vectora,vectorb){vector>r;for(int i=0;i({1,2,3},{4,5,6}); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ज़िप(वेक्टोरा,वेक्टरबी){वेक्टर;for(int i=0;i
A
25 25
B
14 14
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) v[1]={2,5}. first=2, second=5. Output: 25.
व्याख्या (हिन्दी) v[1]={2,5}. पहला=2, दूसरा=5. आउटपुट: 25.
75
EN + हिं
GB What is the output: template T sq(T x){return x*x;} template<> string sq(string s){return s+s;} cout<
IN आउटपुट क्या है: टेम्पलेट T sq(T x){रिटर्न x*x;} टेम्पलेट स्ट्रिंग sq(स्ट्रिंग s){रिटर्न s+s;} कॉउट
A
9abab 9बाबा
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
9 abab 9 अबाब
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sq(3)=9; sq("ab")="ab"+"ab"="abab". Output: 9abab.
व्याख्या (हिन्दी) वर्ग(3)=9; sq('ab''='ab'+'ab'='abab''। आउटपुट: 9abab.
61–75 of 131