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
46
EN + हिं
GB What is the output: template T abs2(T x){return x<0?-x:x;} cout<
IN आउटपुट क्या है: टेम्पलेट T abs2(T x){रिटर्न x
A
53.14 53.14
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
5 3 5 3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) abs2(-5)=5, abs2(-3.14)=3.14. Output: 53.14.
व्याख्या (हिन्दी) abs2(-5)=5, abs2(-3.14)=3.14. आउटपुट: 53.14.
47
EN + हिं
GB What is the output: template int sign(T x){return x>0?1:(x<0?-1:0);} cout<
IN आउटपुट क्या है: टेम्पलेट int साइन(T x){रिटर्न x>0?1:(x
A
-101 -101
B
-101 -101
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sign(-5)=-1, sign(0)=0, sign(3)=1. Output: -101.
व्याख्या (हिन्दी) चिह्न(-5)=-1, चिह्न(0)=0, चिह्न(3)=1. Output: -101.
48
EN + हिं
GB What is the output: template class Wrapper{T v; public: Wrapper(T x):v(x){} T get(){return v;} Wrapper operator+(Wrapper o){return Wrapper(v+o.v);}}; Wrappera(3),b(4); cout<<(a+b).get();
IN आउटपुट क्या है: टेम्पलेट क्लास रैपर{T v; सार्वजनिक: रैपर (टी एक्स): वी (एक्स) {} टी गेट() {रिटर्न वी;} रैपर ऑपरेटर + (रैपर ओ) {रिटर्न रैपर (वी + ओ.वी);}}; रैपपेरा(3),बी(4); अदालत
A
7 7
B
12 12
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3+4=7. Output: 7.
व्याख्या (हिन्दी) 3+4=7. आउटपुट: 7.
49
EN + हिं
GB What is the output: template bool between(T v,T lo,T hi){return v>=lo&&v<=hi;} cout<
IN आउटपुट क्या है: टेम्पलेट बूल बीच(टी वी,टी लो,टी हाय){रिटर्न वी>=लो&&वी
A
10 10
B
11 11
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 in [1,10]=1; 15 not=0. Output: 10.
व्याख्या (हिन्दी) 5 में [1,10]=1; 15 नहीं=0. आउटपुट: 10.
50
EN + हिं
GB What is the output: template T addOne(T x){return x+1;} cout<
IN आउटपुट क्या है: टेम्पलेट T addOne(T x){return x+1;} cout
A
6 6
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) addOne(5)=6. Output: 6.
व्याख्या (हिन्दी) ऐडवन(5)=6. आउटपुट: 6.
51
EN + हिं
GB What is the output: template struct TypeOf{static string name(){return "unknown";}}; template<> struct TypeOf{static string name(){return "int";}}; cout<::name()<::name();
IN आउटपुट क्या है: टेम्प्लेट स्ट्रक्चर टाइपऑफ़ {स्टैटिक स्ट्रिंग नेम() {रिटर्न "अज्ञात";}}; टेम्प्लेट संरचना प्रकारOf{स्थैतिक स्ट्रिंग नाम(){वापसी "int";}}; अदालत
A
intunknown अनजान
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
int double इंट डबल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TypeOf=int; TypeOf=unknown. Output: intunknown.
व्याख्या (हिन्दी) टाइपऑफ=इंट; टाइपऑफ=अज्ञात. आउटपुट: अज्ञात.
52
EN + हिं
GB What is the output: template struct Array{T d[N]; int size(){return N;} T& at(int i){return d[i];}}; Array a; a.at(0)=1;a.at(1)=2;a.at(2)=3; cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर ऐरे {टी डी [एन]; int size(){return N;} T& at(int i){return d[i];}}; सरणी ए; a.at(0)=1;a.at(1)=2;a.at(2)=3; अदालत
A
32 32
B
31 31
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=3, at(1)=2. Output: 32.
व्याख्या (हिन्दी) आकार=3, पर(1)=2. आउटपुट: 32.
53
EN + हिं
GB What is the output: template T myMax(initializer_list il){return *max_element(il.begin(),il.end());} cout<
IN आउटपुट क्या है: टेम्पलेट T myMax(initializer_list il){return *max_element(il.begin(),il.end());} cout
A
9 9
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) max=9. Output: 9.
व्याख्या (हिन्दी) अधिकतम=9. आउटपुट: 9.
54
EN + हिं
GB What is the output: template auto product(Args... args){return (args*...);} cout<
IN आउटपुट क्या है: टेम्प्लेट ऑटो प्रोडक्ट(आर्ग...आर्ग){रिटर्न (आर्ग*...);} कॉउट
A
120 120
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1*2*3*4*5=120. Output: 120.
व्याख्या (हिन्दी) 1*2*3*4*5=120. आउटपुट: 120.
55
EN + हिं
GB What is the output: template T fromString(const string& s); template<> int fromString(const string& s){return stoi(s);} cout<("42");
IN आउटपुट क्या है: टेम्पलेट T fromString(const string& s); टेम्पलेट int fromString(const string& s){return Stoi(s);} cout
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) fromString("42")=42. Output: 42.
व्याख्या (हिन्दी) fromString("42")=42. आउटपुट: 42.
56
EN + हिं
GB What is the output: template struct Cond{using type=T;}; template struct Cond{using type=F;}; cout<::type,int>;
IN आउटपुट क्या है: template struct Cond{using type=T;}; टेम्पलेट संरचना Cond{उपयोग प्रकार=F;}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) true: type=int. is_same=1. Output: 1.
व्याख्या (हिन्दी) सत्य: प्रकार=int. समान=1 है. आउटपुट: 1.
57
EN + हिं
GB What is the output: template struct Decay{using type=remove_cvref_t;}; cout<::type,int>;
IN आउटपुट क्या है: टेम्पलेट संरचना क्षय{उपयोग प्रकार=निकालें_cvref_t;}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) remove_cvref removes const and &. type=int. is_same=1. Output: 1.
व्याख्या (हिन्दी) delete_cvref स्थिरांक और & को हटा देता है। टाइप=इंट. समान=1 है. आउटपुट: 1.
58
EN + हिं
GB What is the output: template void f(T){cout<<'T';} template<> void f(int){cout<<'I';} f(1); f(1.0); f('a');
IN आउटपुट क्या है: टेम्पलेट शून्य f(T){cout
A
ITT आईटीटी
B
TTT टीटीटी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(1): T=int: 'I'. f(1.0): T=double: 'T'. f('a'): T=char: 'T'. Output: ITT.
व्याख्या (हिन्दी) एफ(1): टी=इंट: 'आई'। एफ(1.0): टी=डबल: 'टी'। एफ('ए'): टी=चार: 'टी'। आउटपुट: आईटीटी।
59
EN + हिं
GB What is the output: template auto makeVec(T a,T b,T c)->vector{return {a,b,c};} auto v=makeVec(1,2,3); cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो मेकवेक(टी ए,टी बी,टी सी)->वेक्टर{रिटर्न {ए,बी,सी};} ऑटो वी=मेकवेक(1,2,3); अदालत
A
4 4
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) v[0]=1,v[2]=3. 1+3=4. Output: 4.
व्याख्या (हिन्दी) v[0]=1,v[2]=3. 1+3=4. आउटपुट: 4.
60
EN + हिं
GB What is the output: template struct Twice{using type=pair;}; Twice::type p={3,4}; cout<
IN आउटपुट क्या है: टेम्पलेट संरचना दो बार {उपयोग प्रकार = जोड़ी;}; दो बार::टाइप करें p={3,4}; अदालत
A
34 34
B
43 43
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) pair{3,4}. first=3,second=4. Output: 34.
व्याख्या (हिन्दी) जोड़ी{3,4}. पहला=3, दूसरा=4. आउटपुट: 34.
46–60 of 131