OOP Using C++ — MCQ Practice

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

📚 107 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
107 questions
61
EN + हिं
GB What is the output: class T{public: T(){cout<<'T';} T(const T&){cout<<'C';} ~T(){cout<<'D';}}; T f(T t){return t;} T a; f(a);
IN आउटपुट क्या है: क्लास टी{पब्लिक: टी(){काउट
A
TCCDD टीसीसीडीडी
B
Depends on optimization अनुकूलन पर निर्भर करता है
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) With NRVO: T constructed (T), copy to param (C), copy return (C or elided), destructors. Optimization dependent.
व्याख्या (हिन्दी) एनआरवीओ के साथ: टी निर्मित (टी), कॉपी टू पैरा (सी), कॉपी रिटर्न (सी या एलिडेड), डिस्ट्रक्टर्स। अनुकूलन निर्भर.
62
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v*v){}}; A a(4); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v*v){}}; ए ए(4); अदालत
A
16 16
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=4*4=16. Output: 16.
व्याख्या (हिन्दी) x=4*4=16. आउटपुट: 16.
63
EN + हिं
GB What is the output: class A{public:A(){cout<<1;} A(int){cout<<2;} A(int,int){cout<<3;}}; A a; A b(1); A c(1,2);
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
123 123
B
111 111
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a: default=1; b(1): int=2; c(1,2): int,int=3. Output: 123.
व्याख्या (हिन्दी) ए: डिफ़ॉल्ट=1; बी(1): int=2; सी(1,2): int,int=3. आउटपुट: 123.
64
EN + हिं
GB What is the output: class A{public:int x; constexpr A(int v):x(v){}}; constexpr A a(5); cout<
IN आउटपुट क्या है: class A{public:int x; constexpr A(int v):x(v){}}; constexpr ए ए(5); अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexpr ctor creates a at compile time. a.x=5. Output: 5.
व्याख्या (हिन्दी) संकलन समय पर constexpr ctor एक बनाता है। a.x=5. आउटपुट: 5.
65
EN + हिं
GB What is the output: class A{public:int x=0;}; class B:public A{public:B(){x=5;}}; B b; cout<
IN आउटपुट क्या है: class A{public:int x=0;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:बी(){x=5;}}; बी बी; अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B() sets x=5. Output: 5.
व्याख्या (हिन्दी) बी() x=5 सेट करता है। आउटपुट: 5.
66
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x*2){}}; A a(3); A b(a); A c(b); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x*2){}}; ए ए(3); ए बी(ए); ए सी(बी); अदालत
A
3612 3612
B
336 336
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=3; b.x=3*2=6; c.x=6*2=12. Output: 3612.
व्याख्या (हिन्दी) a.x=3; b.x=3*2=6; c.x=6*2=12. आउटपुट: 3612.
67
EN + हिं
GB What is the output: class A{int x=0; public: A&operator=(int v){x=v;return *this;} int get()const{return x;}}; A a; a=5; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक: A&operator=(int v){x=v;return *this;} int get()const{return x;}}; ए ए; ए=5; अदालत
A
5 5
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=5: operator=(5): x=5. Output: 5.
व्याख्या (हिन्दी) a=5: ऑपरेटर=(5): x=5. आउटपुट: 5.
68
EN + हिं
GB What is the output: class A{public:~A(){cout<<'X';} A()=default; A(A&&)=default;}; A f(){return A();} A a=f(); cout<<'Y';
IN आउटपुट क्या है: क्लास ए{पब्लिक:~ए(){काउट
A
XY XY
B
YX YX
C
Y वाई
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory elision: no move/copy needed. a created directly. At end: ~a prints X. But cout<<'Y' first. Output: YX.
व्याख्या (हिन्दी) C++17 अनिवार्य एलिज़न: कोई स्थानांतरण/प्रतिलिपि की आवश्यकता नहीं है। एक सीधे बनाया गया. अंत में: ~a X प्रिंट करता है। लेकिन कॉउट
69
EN + हिं
GB What is the output: class A{public:int x; A():x(0){} A(int v):x(v){}}; A arr[3]={1,2,3}; cout<
IN आउटपुट क्या है: class A{public:int x; A():x(0){} A(int v):x(v){}}; एक गिरफ्तारी[3]={1,2,3}; अदालत
A
13 13
B
31 31
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) arr[0].x=1, arr[2].x=3. Output: 13.
व्याख्या (हिन्दी) गिरफ्तारी[0].x=1, गिरफ्तारी[2].x=3. आउटपुट: 13.
70
EN + हिं
GB What is the output: class A{public:int x=0; ~A(){x=-1;} int getAfterDtor(){return x;}}; A *p=new A; delete p; // p->getAfterDtor() would be UB
IN आउटपुट क्या है: class A{public:int x=0; ~A(){x=-1;} int getAfterDtor(){return x;}}; ए *पी=नया ए; पी हटाएं; // p->getAfterDtor() यूबी होगा
A
Undefined behavior अपरिभाषित व्यवहार
C
-1 -1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Accessing deleted object is UB.
व्याख्या (हिन्दी) हटाए गए ऑब्जेक्ट तक पहुंच यूबी है।
71
EN + हिं
GB What is the output: class A{public:int x; constexpr A(int v):x(v*v){}}; constexpr A a(4); cout<
IN आउटपुट क्या है: class A{public:int x; constexpr A(int v):x(v*v){}}; constexpr ए ए(4); अदालत
A
16 16
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) constexpr A(4): x=16. Output: 16.
व्याख्या (हिन्दी) constexpr A(4): x=16. आउटपुट: 16.
72
EN + हिं
GB What is the output: class A{public:int x=0,y=0; A()=default; A(int a,int b):x(a),y(b){}}; A a{3,4}; cout<
IN आउटपुट क्या है: class A{public:int x=0,y=0; ए()=डिफ़ॉल्ट; A(int a,int b):x(a),y(b){}}; ए ए{3,4}; अदालत
A
34 34
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
00 00
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A has user-provided constructor so not aggregate; A a{3,4} calls A(int,int). Output: 34.
व्याख्या (हिन्दी) A के पास उपयोगकर्ता द्वारा प्रदत्त कंस्ट्रक्टर है इसलिए समग्र नहीं; A a{3,4} A(int,int) को कॉल करता है। आउटपुट: 34.
73
EN + हिं
74
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} bool operator<(const A& o)const{return x
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} बूल ऑपरेटर
A
1 1
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) min uses operator<; min is c.x=1. Output: 1.
व्याख्या (हिन्दी) न्यूनतम ऑपरेटर का उपयोग करता है
75
EN + हिं
GB What is the output: class A{public:int x=10; A(const A& o):x(o.x-1){} A()=default;}; A a; A b=a; A c=b; A d=c; cout<
IN आउटपुट क्या है: class A{public:int x=10; A(const A&o):x(o.x-1){} A()=default;}; ए ए; ए बी=ए; ए सी=बी; ए डी=सी; अदालत
A
10 9 8 7 10 9 8 7
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
option_b विकल्प_बी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) See explanation.
व्याख्या (हिन्दी) स्पष्टीकरण देखें.
61–75 of 107