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
31
EN + हिं
GB What is the output: template T maxOf(T a,T b){return a>b?a:b;} cout<
IN आउटपुट क्या है: टेम्पलेट T maxOf(T a,T b){return a>b?a:b;} cout
A
72.5 72.5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
3 7 3 7
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) maxOf(3,7)=7, maxOf(2.5,1.5)=2.5. Output: 72.5.
व्याख्या (हिन्दी) maxOf(3,7)=7, maxOf(2.5,1.5)=2.5. आउटपुट: 72.5.
32
EN + हिं
GB What is the output: template struct Pair{T a,b; Pair(T x,T y):a(x),b(y){} T sum(){return a+b;}}; Pair p(3,4); cout<
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर पेयर{T a,b; जोड़ी(टी एक्स,टी वाई):ए(एक्स),बी(वाई){} टी योग(){रिटर्न ए+बी;}}; जोड़ी पी(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.
33
EN + हिं
GB What is the output: template auto add(T a,U b){return a+b;} cout<
IN आउटपुट क्या है: टेम्पलेट ऑटो ऐड(टी ए,यू बी){रिटर्न ए+बी;} कॉउट
A
3.5 3.5
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) int+double=3.5. Output: 3.5.
व्याख्या (हिन्दी) int+डबल=3.5. आउटपुट: 3.5.
34
EN + हिं
GB What is the output: template void print(T v){cout<
IN आउटपुट क्या है: टेम्पलेट शून्य प्रिंट (टी वी) {काउट
A
1 A 3.14 1 ए 3.14
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
1A3 1ए3
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Prints each with space. Output: 1 A 3.14.
व्याख्या (हिन्दी) प्रत्येक को स्थान के साथ प्रिंट करता है। आउटपुट: 1 ए 3.14.
35
EN + हिं
GB What is the output: template struct Square{static const int v=N*N;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट स्ट्रक्चर स्क्वायर {static const int v=N*N;}; अदालत
A
49 49
B
7 7
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7*7=49. Output: 49.
व्याख्या (हिन्दी) 7*7=49. आउटपुट: 49.
36
EN + हिं
GB What is the output: template class Stack{vectorv; public: void push(T x){v.push_back(x);} T top(){return v.back();} int size(){return v.size();}}; Stack s; s.push(1);s.push(2);s.push(3); cout<
IN आउटपुट क्या है: टेम्पलेट क्लास स्टैक{वेक्टरव; सार्वजनिक: शून्य पुश(T x){v.push_back(x);} T टॉप(){रिटर्न v.बैक();} int आकार(){रिटर्न v.आकार();}}; ढेर एस; एस.पुश(1);एस.पुश(2);एस.पुश(3); अदालत
A
33 33
B
13 13
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) top=3, size=3. Output: 33.
व्याख्या (हिन्दी) शीर्ष=3, आकार=3. आउटपुट: 33.
37
EN + हिं
GB What is the output: template int count(Ts...){return sizeof...(Ts);} cout<
IN आउटपुट क्या है: टेम्पलेट int count(Ts...){return sizeof...(Ts);} cout
A
5 5
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5 args. Output: 5.
व्याख्या (हिन्दी) 5 तर्क. आउटपुट: 5.
38
EN + हिं
GB What is the output: template T clamp(T v,T lo,T hi){return vhi?hi:v;} cout<
IN आउटपुट क्या है: टेम्पलेट टी क्लैंप(टी वी,टी लो,टी हाय){रिटर्न वीएचआई?हाय:वी;} कॉउट
A
5101 5101
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
5 10 1 5 10 1
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) clamp(5,1,10)=5, clamp(15,1,10)=10, clamp(-5,1,10)=1. Output: 5101.
व्याख्या (हिन्दी) क्लैंप(5,1,10)=5, क्लैंप(15,1,10)=10, क्लैंप(-5,1,10)=1। आउटपुट: 5101.
39
EN + हिं
GB What is the output: template bool isNull(T* p){return p==nullptr;} int x=5; cout<
IN आउटपुट क्या है: टेम्पलेट बूल isNull(T* p){return p==nullptr;} int x=5; अदालत
A
01 01
B
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) &x!=null=0; nullptr=1. Output: 01.
व्याख्या (हिन्दी) &x!=शून्य=0; nullptr=1. आउटपुट: 01.
40
EN + हिं
GB What is the output: template struct Remove{using type=T;}; template struct Remove{using type=T;}; cout<::type,int>;
IN आउटपुट क्या है: टेम्पलेट संरचना निकालें{प्रकार=टी का उपयोग करके;}; टेम्प्लेट संरचना निकालें{प्रकार=टी का उपयोग करके;}; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Remove::type=int. is_same=true=1. Output: 1.
व्याख्या (हिन्दी) हटाएँ::प्रकार=int. वही=सत्य=1 है. आउटपुट: 1.
41
EN + हिं
GB What is the output: template T sumArr(T* arr,int n){T s{}; for(int i=0;i
IN आउटपुट क्या है: टेम्पलेट T sumArr(T* arr,int n){T s{}; for(int i=0;i
A
15 15
B
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sum=15. Output: 15.
व्याख्या (हिन्दी) योग=15. आउटपुट: 15.
42
EN + हिं
GB What is the output: template struct IsVoid{static const bool v=false;}; template<> struct IsVoid{static const bool v=true;}; cout<::v<::v;
IN आउटपुट क्या है: टेम्पलेट struct IsVoid{static const bool v=false;}; टेम्पलेट संरचना IsVoid{static const bool v=true;}; अदालत
A
10 10
B
01 01
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) void=1, int=0. Output: 10.
व्याख्या (हिन्दी) शून्य=1, पूर्णांक=0. आउटपुट: 10.
43
EN + हिं
GB What is the output: template T power(T base,int exp){return exp?base*power(base,exp-1):1;} cout<
IN आउटपुट क्या है: टेम्पलेट T पॉवर(T बेस,int exp){रिटर्न exp?base*power(base,exp-1):1;} cout
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.
44
EN + हिं
GB What is the output: template struct GCD{static const int v=GCD::v;}; template struct GCD{static const int v=N;}; cout<::v;
IN आउटपुट क्या है: टेम्पलेट struct GCD{static const int v=GCD::v;}; टेम्पलेट संरचना GCD{static const int v=N;}; अदालत
A
6 6
B
18 18
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(48,18)=6. Output: 6.
व्याख्या (हिन्दी) जीसीडी(48,18)=6. आउटपुट: 6.
45
EN + हिं
GB What is the output: template void swap2(T& a,T& b){T t=a;a=b;b=t;} int x=3,y=7; swap2(x,y); cout<
IN आउटपुट क्या है: टेम्पलेट void swim2(T& a,T& b){T t=a;a=b;b=t;} int x=3,y=7; स्वैप2(एक्स,वाई); अदालत
A
73 73
B
37 37
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=7,y=3. Output: 73.
व्याख्या (हिन्दी) x=7,y=3. आउटपुट: 73.
31–45 of 131