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
1711
EN + हिं
GB What is the output: class A{int* p; public:A(int v):p(new int(v)){} ~A(){delete p;} A(const A& o):p(new int(*o.p)){} int get()const{return *p;}}; A a(5); A b=a; *b.p=10; cout<
IN आउटपुट क्या है: class A{int* p; सार्वजनिक:ए(int v):p(नया int(v)){} ~A(){delete p;} A(const A& o):p(new int(*o.p)){} int get()const{return *p;}}; ए ए(5); ए बी=ए; *बी.पी=10; अदालत
A
510 510
B
1010 1010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Deep copy: b has own int. *b.p=10. a unchanged=5. Output: 510.
व्याख्या (हिन्दी) डीप कॉपी: बी का अपना इंट है। *बी.पी=10. एक अपरिवर्तित=5. आउटपुट: 510.
1712
EN + हिं
GB What is the output: class A{public:int x; A():x(0){cout<<'0';} A(int v):x(v){cout<<'I';} ~A(){cout<<'D';}}; A arr[3];
IN आउटपुट क्या है: class A{public:int x; A():x(0){cout
A
000DDD 000डीडीडी
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
0I0DDD 0आई0डीडीडी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 3 default ctors: 000. 3 dtors: DDD. Output: 000DDD.
व्याख्या (हिन्दी) 3 डिफ़ॉल्ट ctors: 000. 3 dtors: DDD. आउटपुट: 000DDD.
1713
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A operator+(const A& o){return A(x+o.x);} A& operator+=(const A& o){x+=o.x;return *this;}}; A a(3),b(4); a+=b; cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A ऑपरेटर+(const A& o){रिटर्न A(x+o.x);} A& ऑपरेटर+=(const A& o){x+=o.x;रिटर्न *यह;}}; ए ए(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.
1714
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(A&& o):x(exchange(o.x,0)){}}; A a(5); A b=move(a); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(A&& o):x(exchange(o.x,0)){}}; ए ए(5); ए बी = चाल (ए); अदालत
A
05 05
B
50 50
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) exchange(a.x,0) returns 5, sets a.x=0. b.x=5. Output: 05.
व्याख्या (हिन्दी) एक्सचेंज(a.x,0) 5 लौटाता है, a.x=0 सेट करता है। बी.एक्स=5. आउटपुट: 05.
1715
EN + हिं
GB What is the output: class A{public:vectorv; A(initializer_listil):v(il){}}; A a={1,2,3,4,5}; cout<
IN आउटपुट क्या है: class A{public:vectorv; ए(इनिशियलाइज़र_लिस्टिल):v(il){}}; ए ए={1,2,3,4,5}; अदालत
A
53 53
B
51 51
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) size=5, v[2]=3. Output: 53.
व्याख्या (हिन्दी) आकार=5, वी[2]=3. आउटपुट: 53.
1716
EN + हिं
GB What is the output: class A{int x; public:A(int v):x(v){} friend bool operator<(const A& a,const A& b){return a.x
IN आउटपुट क्या है: class A{int x; सार्वजनिक:ए(int v):x(v){} मित्र बूल ऑपरेटर
A
14 14
B
34 34
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted: 1,2,3,4. arr[0].x=1,arr[3].x=4. Output: 14.
व्याख्या (हिन्दी) क्रमबद्ध: 1,2,3,4. गिरफ्तारी[0].x=1, गिरफ्तारी[3].x=4. आउटपुट: 14.
1717
EN + हिं
GB What is the output: class A{public:int x; explicit A(int v):x(v){}}; A a=A(5); cout<
IN आउटपुट क्या है: class A{public:int x; स्पष्ट A(int v):x(v){}}; ए ए=ए(5); अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(5) explicitly. a.x=5. Output: 5.
व्याख्या (हिन्दी) ए(5) स्पष्ट रूप से। a.x=5. आउटपुट: 5.
1718
EN + हिं
GB What is the output: class A{public:int x=42; A()=default;}; A a{}; cout<
IN आउटपुट क्या है: class A{public:int x=42; ए()=डिफ़ॉल्ट;}; ए ए{}; अदालत
A
42 42
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default ctor uses in-class init x=42. Output: 42.
व्याख्या (हिन्दी) डिफ़ॉल्ट ctor इन-क्लास init x=42 का उपयोग करता है। आउटपुट: 42.
1719
EN + हिं
GB What is the output: class A{public:int x,y; A(int a,int b):y(b),x(a+y){}}; A a(1,2); cout<
IN आउटपुट क्या है: class A{public:int x,y; A(int a,int b):y(b),x(a+y){}}; ए ए(1,2); अदालत
A
Undefined behavior अपरिभाषित व्यवहार
B
32 32
C
12 12
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Members init in declaration order: x first, then y. x=a+y where y is uninitialized = UB.
व्याख्या (हिन्दी) सदस्य घोषणा क्रम में आरंभ करते हैं: पहले x, फिर y। x=a+y जहां y आरंभीकृत नहीं है = UB.
1720
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} auto clone(){return A(x);}}; A a(5); auto b=a.clone(); b.x=10; cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} ऑटो क्लोन(){रिटर्न A(x);}}; ए ए(5); ऑटो b=a.clone(); b.x=10; अदालत
A
510 510
B
1010 1010
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b is new A(5). b.x=10. a.x=5. Output: 510.
व्याख्या (हिन्दी) b नया A(5) है। बी.एक्स=10. a.x=5. आउटपुट: 510.
1721
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){cout
A
3-4 3-4
B
33 33
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ctor prints 3; dtor prints ~3=-4. Output: 3-4.
व्याख्या (हिन्दी) ctor प्रिंट्स 3; डीटीओआर ~3=-4 प्रिंट करता है। आउटपुट: 3-4.
1722
EN + हिं
GB What is the output: class A{public:int x=1; A()=default; A(const A&o):x(o.x+1){}}; A a,b(a),c(b); cout<
IN आउटपुट क्या है: class A{public:int x=1; ए()=डिफ़ॉल्ट; A(const A&o):x(o.x+1){}}; ए ए,बी(ए),सी(बी); अदालत
A
123 123
B
111 111
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.x=1; b.x=1+1=2; c.x=2+1=3. Output: 123.
व्याख्या (हिन्दी) a.x=1; b.x=1+1=2; c.x=2+1=3. आउटपुट: 123.
1723
EN + हिं
GB What is the output: class A{int x; public:explicit A(int v):x(v){} explicit A(double v):x((int)v){} int get()const{return x;}}; A a(3.7); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक:स्पष्ट A(int v):x(v){} स्पष्ट A(डबल v):x((int)v){} int get()const{return x;}}; ए ए(3.7); अदालत
A
3 3
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (int)3.7=3. Output: 3.
व्याख्या (हिन्दी) (int)3.7=3. आउटपुट: 3.
1724
EN + हिं
GB What is the output: class Base{public:Base(){cout<<'B';} ~Base(){cout<<'b';}}; class Der:public Base{public:Der(){cout<<'D';} ~Der(){cout<<'d';}}; Der d;
IN आउटपुट क्या है: क्लास बेस {पब्लिक: बेस() {काउट
A
BDdb बीडीडीबी
B
BdDb बीडीडीबी
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B,D,~d,~b. Output: BDdb.
व्याख्या (हिन्दी) बी,डी,~डी,~बी. आउटपुट: बीडीडीबी.
1725
EN + हिं
GB What is the output: class A{public:int x; A(int v=0):x(v){} A(const A&)=default; A(A&&o)noexcept:x(move(o.x)){o.x=-1;}}; A a(5); A b(move(a)); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v=0):x(v){} A(const A&)=default; A(A&&o)noexcept:x(move(o.x)){o.x=-1;}}; ए ए(5); ए बी(चाल(ए)); अदालत
A
-15 -15
B
55 55
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.x=5; a.x=-1. Output: -15.
व्याख्या (हिन्दी) बी.एक्स=5; a.x=-1. आउटपुट:-15.
1711–1725 of 1915