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
46
EN + हिं
GB What is the output: class A{public:int x=1,y=2; A(int v):y(v),x(y){}}; A a(5); cout<
IN आउटपुट क्या है: class A{public:int x=1,y=2; A(int v):y(v),x(y){}}; ए ए(5); अदालत
A
25 25
B
15 15
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x initialized first (declaration order): x=y is UB — y not yet initialized. Undefined.
व्याख्या (हिन्दी) x को पहले प्रारंभ किया गया (घोषणा क्रम): x=y यूबी है - y को अभी तक प्रारंभ नहीं किया गया है। अपरिभाषित.
47
EN + हिं
48
EN + हिं
GB What is the output: class A{public:A(){cout<<'A';}}; class B{public:B(){cout<<'B';}}; class C:public A{B b; public:C(){cout<<'C';}}; C c;
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
ABC एबीसी
B
CBA सीबीए
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A() base first, B() member next, C() body last. Output: ABC.
व्याख्या (हिन्दी) A() आधार पहले, B() सदस्य अगला, C() निकाय अंतिम। आउटपुट: एबीसी.
49
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x+10){}}; A a(5); A b(a); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(const A& o):x(o.x+10){}}; ए ए(5); ए बी(ए); अदालत
A
515 515
B
510 510
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=5; b.x=a.x+10=15. Output: 515.
व्याख्या (हिन्दी) a.x=5; b.x=a.x+10=15. आउटपुट: 515.
50
EN + हिं
GB What is the output: class A{public:int x=0; A(){} A(A&&o):x(o.x){o.x=-1;}}; A a; a.x=5; A b=move(a); cout<
IN आउटपुट क्या है: class A{public:int x=0; A(){} A(A&&o):x(o.x){o.x=-1;}}; ए ए; a.x=5; ए बी = चाल (ए); अदालत
A
-15 -15
B
5-1 5-1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) -1 then 5. Output: -15.
व्याख्या (हिन्दी) -1 फिर 5. आउटपुट: -15.
51
EN + हिं
GB What is the output: class A{static int n; public: A(){n++;} ~A(){n (1, 6, 79, 9, 4, 'What is the output: class A{public:int* p; A():p(new int(5)){} A(const A& o):p(new int(*o.p)){} ~A(){delete p;}}; A a; A b=a; *b.p=10; cout<<*a.p<<*b.p;', 'Deep copy ctor?', '510', '510', '1010', '1010', 'Compile error', 'Compile error', 'Undefined', 'Undefined', NULL, 'option_a', 'Deep copy: b gets own int. *b.p=10 doesn't affect *a.p=5. Output: 510.
IN आउटपुट क्या है: class A{static int n; सार्वजनिक: A(){n++;} ~A(){n (1, 6, 79, 9, 4, 'आउटपुट क्या है: क्लास ए {सार्वजनिक: int * p; A():p(new int(5)){} A(const A& o):p(new int(*op.p)){} ~A(){delete p;}}; A a; A b=a; *b.p=10; cout
A
2026-05-25 2026-05-25
✅ Correct Answer:
52
EN + हिं
GB What is the output: class A{public:int* p; A():p(new int(5)){} A(const A& o):p(new int(*o.p)){} ~A(){delete p;}}; A a; A b=a; *b.p=10; cout<<*a.p<<*b.p;
IN आउटपुट क्या है: class A{public:int* p; A():p(new int(5)){} A(const A& o):p(new int(*o.p)){} ~A(){delete p;}}; ए ए; ए बी=ए; *बी.पी=10; अदालत
A
510 510
B
1010 1010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Deep copy: b gets own int. *b.p=10 doesn't affect *a.p=5. Output: 510.
व्याख्या (हिन्दी) डीप कॉपी: बी को अपना इंट मिलता है। *बी.पी=10 *ए.पी=5 को प्रभावित नहीं करता। आउटपुट: 510.
53
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A& operator=(const A& o){x=o.x; return *this;}}; A a(3),b(5); a=b; cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A& ऑपरेटर=(const A& o){x=o.x; वापसी *यह;}}; ए ए(3),बी(5); ए=बी; अदालत
A
5 5
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=b.x=5. Output: 5.
व्याख्या (हिन्दी) a.x=b.x=5. आउटपुट: 5.
54
EN + हिं
GB What is the output: class A{public:~A()=default; A()=default;}; A a; cout<<'X';
IN आउटपुट क्या है: class A{public:~A()=default; ए()=डिफ़ॉल्ट;}; ए ए; अदालत
A
X एक्स
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Valid; prints X. Output: X.
व्याख्या (हिन्दी) वैध; एक्स प्रिंट करता है। आउटपुट: एक्स।
55
EN + हिं
GB What is the output: class A{public:A(){cout<<'N';} A(int){cout<<'I';} A(double){cout<<'D';} A(const A&){cout<<'C';}}; A a=5; A b=5.0; A c=a;
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए() {काउट
A
IDC आईडीसी
B
NIC एनआईसी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=5: A(int)=I; b=5.0: A(double)=D; c=a: copy=C. Output: IDC.
व्याख्या (हिन्दी) a=5: A(int)=I; बी=5.0: ए(डबल)=डी; सी=ए: कॉपी=सी. आउटपुट: आईडीसी.
56
EN + हिं
GB What is the output: class A{public:int x; A(initializer_list il):x(*il.begin()){}}; A a={42,1,2}; cout<
IN आउटपुट क्या है: class A{public:int x; A(initializer_list il):x(*il.begin()){}}; ए ए={42,1,2}; अदालत
A
42 42
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=*begin(il)=42. Output: 42.
व्याख्या (हिन्दी) x=*शुरू(il)=42. आउटपुट: 42.
57
EN + हिं
GB What is 'deleted special member'?
IN 'हटाए गए विशेष सदस्य' क्या है?
A
=delete explicitly disables the function =delete फ़ंक्शन को स्पष्ट रूप से अक्षम कर देता है
B
Makes function private फ़ंक्शन को निजी बनाता है
C
Pure virtual शुद्ध आभासी
D
Not callable कॉल करने योग्य नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(const A&)=delete; prevents copy construction; attempting it is a compile error.
व्याख्या (हिन्दी) ए(स्थिरांक ए&)=हटाएं; प्रतिलिपि निर्माण को रोकता है; इसका प्रयास करना एक संकलन त्रुटि है।
58
EN + हिं
GB What is the output: class A{public:int x; A():x(0){} A(A&&o) noexcept:x(o.x){o.x=0;} A(const A&)=delete;}; A f(){return A();} A a=f(); cout<
IN आउटपुट क्या है: class A{public:int x; A():x(0){} A(A&&o) noexcept:x(o.x){o.x=0;} A(const A&)=delete;}; A f(){वापसी A();} A a=f(); अदालत
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
5 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A() created then moved/elided into a. a.x=0. Output: 0.
व्याख्या (हिन्दी) A() बनाया गया और फिर a में स्थानांतरित/एलिंड किया गया। a.x=0. आउटपुट: 0.
59
EN + हिं
GB What is the output: class A{public:int x=0; A(int v):x(v){} A& operator+=(const A& o){x+=o.x;return *this;}}; A a(3),b(4); a+=b; cout<
IN आउटपुट क्या है: class A{public:int x=0; A(int v):x(v){} A& ऑपरेटर+=(const A& o){x+=o.x;return *this;}}; ए ए(3),बी(4); ए+=बी; अदालत
A
7 7
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=3+4=7. Output: 7.
व्याख्या (हिन्दी) a.x=3+4=7. आउटपुट: 7.
60
EN + हिं
GB What is the output: class A{int x; public: void setX(int v){x=v;} int getX()const{return x;} A():x(100){}}; A a; cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक: void setX(int v){x=v;} int getX()const{return x;} A():x(100){}}; ए ए; अदालत
A
100200 100200
B
200200 200200
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Initial x=100; after setX(200): x=200. Output: 100200.
व्याख्या (हिन्दी) आरंभिक x=100; सेटएक्स(200) के बाद: x=200। आउटपुट: 100200.
46–60 of 107