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
1426
EN + हिं
GB What is the output: template struct Opt{bool h;T v; Opt():h(false){} Opt(T x):h(true),v(x){} T or_(T d){return h?v:d;}}; Opt a(5),b; cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर ऑप्ट{बूल एच;टी वी; Opt():h(false){} Opt(T x):h(true),v(x){} T या_(T d){return h?v:d;}}; ऑप्ट ए(5),बी; अदालत
A
599 599
B
50 50
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a has value 5; b empty. Output: 599.
व्याख्या (हिन्दी) a का मान 5 है; बी खाली. आउटपुट: 599.
1427
EN + हिं
GB What is the output: template T myAbs(T x){return x<0?-x:x;} cout<
IN आउटपुट क्या है: टेम्पलेट T myAbs(T x){रिटर्न x
A
53.14 53.14
B
5 3 5 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 and 3.14. Output: 53.14.
व्याख्या (हिन्दी) 5 और 3.14. आउटपुट: 53.14.
1428
EN + हिं
GB What is the output: template bool same(T a,U b){return is_same_v&&a==b;} cout<
IN आउटपुट क्या है: टेम्पलेट बूल समान(T a,U b){return is_same_v&&a==b;} cout
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) same(5,5): T=U=int, 5==5=1. same(5,5.0): T=int,U=double: is_same=false=0. Output: 10.
व्याख्या (हिन्दी) वही(5,5): टी=यू=इंट, 5==5=1। समान(5,5.0): T=int,U=डबल: is_same=false=0. आउटपुट: 10.
1429
EN + हिं
GB What is the output: template struct Bits{static const int v=1<::v<::v<::v;
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर बिट्स {static const int v=1
A
1 8 128 1 8 128
B
18128 18128
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1<<0=1; 1<<3=8; 1<<7=128. Output: 18128.
व्याख्या (हिन्दी) 1
1430
EN + हिं
GB What is the output: template struct Neg{using type=T;}; template<> struct Neg{using type=unsigned;}; Neg::type x=-1; cout<
IN आउटपुट क्या है: टेम्पलेट संरचना नकारात्मक{उपयोग प्रकार=टी;}; टेम्पलेट संरचना नकारात्मक{प्रकार का उपयोग करके=अहस्ताक्षरित;}; नकारात्मक::प्रकार x=-1; अदालत
A
4294967295 4294967295
B
-1 -1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) type=unsigned; unsigned x=-1=UINT_MAX. Output: 4294967295.
व्याख्या (हिन्दी) प्रकार=अहस्ताक्षरित; अहस्ताक्षरित x=-1=UINT_MAX. आउटपुट: 4294967295.
1431
EN + हिं
GB What is the output: template struct Count{static const int v=sizeof...(Ts);}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर काउंट {static const int v=sizeof...(Ts);}; अदालत
A
3 3
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sizeof...=3. Output: 3.
व्याख्या (हिन्दी) आकार...=3. आउटपुट: 3.
1432
EN + हिं
GB What is the output: template T mid(T a,T b,T c){T s[]={a,b,c};sort(s,s+3);return s[1];}cout<
IN आउटपुट क्या है: टेम्पलेट टी मिड(टी ए,टी बी,टी सी){टी एस[]={ए,बी,सी};सॉर्ट(एस,एस+3);रिटर्न एस[1];}काउट
A
5 5
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 3,5,7. Middle=5. Output: 5.
व्याख्या (हिन्दी) क्रमबद्ध: 3,5,7. मध्य=5. आउटपुट: 5.
1433
EN + हिं
GB What is the output: template struct YN{static const char v='N';}; template<> struct YN{static const char v='Y';}; cout<1)>::v;
IN आउटपुट क्या है: टेम्पलेट struct YN{static const char v='N';}; टेम्पलेट संरचना YN{static const char v='Y';}; अदालत
A
Y वाई
B
N एन
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2>1=true: YN::v='Y'. Output: Y.
व्याख्या (हिन्दी) 2>1=सत्य: YN::v='Y'। आउटपुट: वाई.
1434
EN + हिं
GB What is the output: template struct Zero{static constexpr T v=T{};}; cout<::v<::v<::v;
IN आउटपुट क्या है: टेम्पलेट struct Zero{static constexpr T v=T{};}; अदालत
A
000 000
B
010 010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int{}=0, double{}=0, bool{}=false=0. Output: 000.
व्याख्या (हिन्दी) int{}=0, डबल{}=0, बूल{}=झूठा=0। आउटपुट: 000.
1435
EN + हिं
GB What is the output: template struct Constant{static constexpr T value=V;}; using Five=Constant; cout<
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर कॉन्स्टैंट {स्थैतिक कॉन्स्टेक्सपीआर टी वैल्यू = वी;}; पाँच=स्थिरांक का उपयोग करना; अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Five::value=5. Output: 5.
व्याख्या (हिन्दी) पाँच::मान=5. आउटपुट: 5.
1436
EN + हिं
GB What is the output: template T dot(vectora,vectorb){T s=T{};for(int i=0;i({1,2,3},{4,5,6});
IN आउटपुट क्या है: टेम्पलेट T dot(vectora,vectorb){T s=T{};for(int i=0;i
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.
1437
EN + हिं
GB What is the output: template struct IsSame{template static bool f(){return false;} template<> static bool f(){return true;}}; cout<::f()<::f();
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर IsSame{टेम्पलेट स्टैटिक बूल f(){रिटर्न फॉल्स;} टेम्प्लेट स्टैटिक बूल f(){रिटर्न ट्रू;}}; अदालत
A
Compile error संकलन त्रुटि
B
10 10
C
11 11
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Explicit specialization of member template inside class body is not allowed. Compile error.
व्याख्या (हिन्दी) क्लास बॉडी के अंदर सदस्य टेम्पलेट की स्पष्ट विशेषज्ञता की अनुमति नहीं है। संकलन त्रुटि.
1438
EN + हिं
GB What is the output: template struct Add{static const int v=A+B;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट संरचना जोड़ें{static const int v=A+B;}; अदालत
A
30 30
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10+20=30. Output: 30.
व्याख्या (हिन्दी) 10+20=30. आउटपुट: 30.
1439
EN + हिं
GB What is the output: template void swap3(T& a,T& b,T& c){T t=a;a=b;b=c;c=t;} int x=1,y=2,z=3; swap3(x,y,z); cout<
IN आउटपुट क्या है: टेम्पलेट void swim3(T& a,T& b,T& c){T t=a;a=b;b=c;c=t;} int x=1,y=2,z=3; स्वैप3(x,y,z); अदालत
A
231 231
B
123 123
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=b=2; b=c=3; c=t=1. x=2,y=3,z=1. Output: 231.
व्याख्या (हिन्दी) ए=बी=2; बी=सी=3; सी=टी=1. x=2,y=3,z=1. आउटपुट: 231.
1440
EN + हिं
GB What is the output: template class Vec2{public:T x,y; Vec2(T a,T b):x(a),y(b){} T dot(Vec2 o){return x*o.x+y*o.y;}}; Vec2a(1,2),b(3,4); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास Vec2{public:T x,y; Vec2(T a,T b):x(a),y(b){} T dot(Vec2 o){return x*o.x+y*o.y;}}; Vec2a(1,2),b(3,4); अदालत
A
11 11
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*3+2*4=11. Output: 11.
व्याख्या (हिन्दी) 1*3+2*4=11. आउटपुट: 11.
1426–1440 of 1915