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
856
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.
857
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.
858
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.
859
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.
860
EN + हिं
GB What is the output: class A{public:void f(){cout<<'A';}}; class B:public A{public:void f(){cout<<'B';}}; B b; b.f(); b.A::f();
IN आउटपुट क्या है: कक्षा ए {सार्वजनिक: शून्य एफ() {काउट
A
BA बी ० ए
B
AB अब
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.f()=B, b.A::f()=A. Output: BA.
व्याख्या (हिन्दी) b.f()=B, b.A::f()=A. आउटपुट: बी.ए.
861
EN + हिं
GB What is the output: class A{public:int x=1;}; class B:public A{public:int y=2;}; B b; cout<
IN आउटपुट क्या है: class A{public:int x=1;}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int y=2;}; बी बी; अदालत
A
12 12
B
21 21
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.x=1 (from A), b.y=2. Output: 12.
व्याख्या (हिन्दी) b.x=1 (ए से), b.y=2. आउटपुट: 12.
862
EN + हिं
863
EN + हिं
GB What is the output: class A{protected:int x=10;}; class B:public A{public:void show(){cout<
IN आउटपुट क्या है: class A{protected:int x=10;}; कक्षा बी: सार्वजनिक ए {सार्वजनिक: शून्य शो() {काउट
A
10 10
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=10 accessible in B. Output: 10.
व्याख्या (हिन्दी) x=10 बी में पहुंच योग्य। आउटपुट: 10।
864
EN + हिं
GB What is the output: class A{public:A(int){cout<<'A';}}; class B:public A{public:B():A(5){cout<<'B';}}; B b;
IN आउटपुट क्या है: क्लास ए {पब्लिक: ए (इंट) {काउट
A
AB अब
B
BA बी ० ए
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A(5) first=A, then B=B. Output: AB.
व्याख्या (हिन्दी) ए(5) पहले=ए, फिर बी=बी। आउटपुट: एबी.
865
EN + हिं
GB What is 'virtual inheritance' use case?
IN 'वर्चुअल इनहेरिटेंस' उपयोग मामला क्या है?
A
Diamond: ensure single base subobject हीरा: एकल आधार उपवस्तु सुनिश्चित करें
B
Performance optimization प्रदर्शन अनुकूलन
C
Multiple return types एकाधिक रिटर्न प्रकार
D
Template specialization टेम्पलेट विशेषज्ञता
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) class B:virtual public A{}; class C:virtual public A{}; class D:public B,C{}; D has one A.
व्याख्या (हिन्दी) कक्षा बी:वर्चुअल पब्लिक ए{}; क्लास सी:वर्चुअल पब्लिक ए{}; कक्षा डी:सार्वजनिक बी,सी{}; D के पास एक A है.
866
EN + हिं
GB What is the output: class A{public:virtual int f(){return 1;}}; class B:public A{public:int f()override{return 2;}}; class C:public B{public:int f()override{return 3;}}; A*p=new C; cout<f();
IN आउटपुट क्या है: क्लास ए{पब्लिक:वर्चुअल इंट एफ(){रिटर्न 1;}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int f()ओवरराइड{वापसी 2;}}; कक्षा सी:सार्वजनिक बी{सार्वजनिक:int f()ओवरराइड{वापसी 3;}}; ए*पी=नया सी; अदालत
A
3 3
B
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C::f() is most derived. Output: 3.
व्याख्या (हिन्दी) C::f() सबसे अधिक व्युत्पन्न है। आउटपुट: 3.
867
EN + हिं
GB What is the output: class A{public:void f(){cout<<1;}}; class B:public A{public:void f(){cout<<2;} void g(){A::f(); f();}}; B b; b.g();
IN आउटपुट क्या है: कक्षा ए {सार्वजनिक: शून्य एफ() {काउट
A
12 12
B
21 21
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A::f()=1; f()=B::f()=2. Output: 12.
व्याख्या (हिन्दी) ए::एफ()=1; एफ()=बी::एफ()=2. आउटपुट: 12.
868
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){}}; class B:public A{public:int y; B(int a,int b):A(a),y(b){}}; B b(3,4); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){}}; कक्षा बी:सार्वजनिक ए{सार्वजनिक:int y; B(int a,int b):A(a),y(b){}}; बी बी(3,4); अदालत
A
34 34
B
43 43
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x=3,y=4. Output: 34.
व्याख्या (हिन्दी) x=3,y=4. आउटपुट: 34.
869
EN + हिं
GB What is the output: class A{public:static void f(){cout<<'S';}}; class B:public A{}; B::f();
IN आउटपुट क्या है: वर्ग ए {सार्वजनिक: स्थिर शून्य एफ() {काउट
A
S एस
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
D
Nothing कुछ नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) B inherits A::f. B::f()=S. Output: S.
व्याख्या (हिन्दी) B को A::f विरासत में मिला है। बी::एफ()=एस। आउटपुट: एस.
870
EN + हिं
GB What is the output: class A{public:virtual void f(){cout<<'A';}}; class B:public A{public:void f()final{cout<<'B';}}; B b; b.f();
IN आउटपुट क्या है: क्लास ए {पब्लिक: वर्चुअल शून्य एफ() {काउट
A
B बी
B
A
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b.f() calls B::f()=B. Output: B.
व्याख्या (हिन्दी) b.f() कॉल B::f()=B. आउटपुट: बी.
856–870 of 1915