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
1696
EN + हिं
GB What is the output: class A{public:int x; constexpr A(int v):x(v){} constexpr int sq()const{return x*x;}}; constexpr A a(4); constexpr int r=a.sq(); cout<
IN आउटपुट क्या है: class A{public:int x; constexpr A(int v):x(v){} constexpr int sq()const{return x*x;}}; constexpr ए ए(4); constexpr int r=a.sq(); अदालत
A
16 16
B
4 4
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a.sq()=16. Output: 16.
व्याख्या (हिन्दी) a.sq()=16. आउटपुट: 16.
1697
EN + हिं
GB What is the output: class A{public:int x=0; void f(int v=x){}};
IN आउटपुट क्या है: class A{public:int x=0; शून्य f(int v=x){}};
A
Compile error संकलन त्रुटि
B
Works काम करता है
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default argument cannot refer to non-static member. Compile error.
व्याख्या (हिन्दी) डिफ़ॉल्ट तर्क गैर-स्थैतिक सदस्य को संदर्भित नहीं कर सकता। संकलन त्रुटि.
1698
EN + हिं
GB What is the output: class A{public: int x; A(int v):x(v){} friend ostream& operator<<(ostream&os,const A&a){return os<
IN आउटपुट क्या है: क्लास ए {सार्वजनिक: int x; A(int v):x(v){} मित्र ओस्ट्रीम& ऑपरेटर
A
42 42
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Friend operator<< outputs x=42. Output: 42.
व्याख्या (हिन्दी) मित्र संचालिका
1699
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A& operator++(){++x;return *this;} A operator++(int){A t=*this;++x;return t;}}; A a(5); cout<<(a++).x<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A& ऑपरेटर++(){++x;रिटर्न *यह;} ए ऑपरेटर++(int){A t=*this;++x;रिटर्न t;}}; ए ए(5); अदालत
A
577 577
B
567 567
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a++=5(a=6); a.x=6; ++a: a=7, returns 7. Output: 567.
व्याख्या (हिन्दी) ए++=5(ए=6); a.x=6; ++a: a=7, रिटर्न 7. आउटपुट: 567.
1700
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){cout<<'C';} ~A(){cout<<'D';} A(A&&o):x(o.x){o.x=0;cout<<'M';}}; A f(){return A(5);} A a=f(); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){cout
A
C5 सी 5
B
CM5 सीएम5
C
CCD5 सीसीडी5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory elision: only one C, no move. a.x=5. Output: C5D (D at scope end, but question asks output before scope end: C5).
व्याख्या (हिन्दी) C++17 अनिवार्य एलिशन: केवल एक C, कोई चाल नहीं। a.x=5. आउटपुट: C5D (D स्कोप अंत में है, लेकिन प्रश्न स्कोप अंत से पहले आउटपुट पूछता है: C5)।
1701
EN + हिं
GB What is the output: class A{public:int x=0; A(){} A(int v):x(v){} A(const A& o):x(o.x*2){}}; A a(3); A b; b=a; cout<
IN आउटपुट क्या है: class A{public:int x=0; A(){} A(int v):x(v){} A(const A& o):x(o.x*2){}}; ए ए(3); ए बी; बी=ए; अदालत
A
3 3
B
6 6
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) b=a uses compiler-generated assignment (copies x). b.x=3. Output: 3.
व्याख्या (हिन्दी) b=a कंपाइलर-जनरेटेड असाइनमेंट (कॉपी x) का उपयोग करता है। बी.एक्स=3. आउटपुट: 3.
1702
EN + हिं
GB What is the output: class A{public:int x; A():x(0){cout<<'D';} A(int v):x(v){cout<<'P';} A(const A&o):x(o.x){cout<<'C';}}; A a=5;
IN आउटपुट क्या है: class A{public:int x; A():x(0){cout
A
P पी
B
C सी
C
D डी
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) A a=5: copy-initialization from int: A(int) called. Output: P.
व्याख्या (हिन्दी) A a=5: int से कॉपी-इनिशियलाइज़ेशन: A(int) कहा जाता है। आउटपुट: पी.
1703
EN + हिं
GB What is the output: class A{public:int x; A(int v=10):x(v){} ~A(){cout<
IN आउटपुट क्या है: class A{public:int x; A(int v=10):x(v){} ~A(){cout
A
151 151
B
1510 1510
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Destructors: ~c(1),~b(5),~a(10). Output: 1510.
व्याख्या (हिन्दी) विध्वंसक: ~सी(1),~बी(5),~ए(10)। आउटपुट: 1510.
1704
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A& operator=(int v){x=v;return *this;}}; A a(3); a=5; cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A& ऑपरेटर=(int v){x=v;रिटर्न *यह;}}; ए ए(3); ए=5; अदालत
A
5 5
B
3 3
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=5: operator=(5): x=5. Output: 5.
व्याख्या (हिन्दी) a=5: ऑपरेटर=(5): x=5. आउटपुट: 5.
1705
EN + हिं
GB What is the output: class A{public:string s; A(string t):s(move(t)){}}; A a("hello"); cout<
IN आउटपुट क्या है: क्लास ए{पब्लिक:स्ट्रिंग एस; ए(स्ट्रिंग टी):एस(मूव(टी)){}}; ए ए('हैलो'); अदालत
A
hello नमस्ते
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) s initialized by moving t. a.s="hello". Output: hello.
व्याख्या (हिन्दी) s को t ले जाकर प्रारंभ किया गया। a.s='हैलो'। आउटपुट: नमस्ते.
1706
EN + हिं
GB What is the output: class A{public:int x,y; A(int a,int b):x(a),y(b){} A(pairp):A(p.first,p.second){}}; A a({3,4}); cout<
IN आउटपुट क्या है: class A{public:int x,y; A(int a,int b):x(a),y(b){} A(pairp):A(p.first,p.Second){}}; ए ए({3,4}); अदालत
A
34 34
B
43 43
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Delegates to A(3,4). x=3,y=4. Output: 34.
व्याख्या (हिन्दी) ए(3,4) को प्रतिनिधि। x=3,y=4. आउटपुट: 34.
1707
EN + हिं
GB What is the output: class A{public:int x; A(int v):x(v){} A(const A& o)=delete;}; A f(){return A(5);} A a=f(); cout<
IN आउटपुट क्या है: class A{public:int x; A(int v):x(v){} A(const A& o)=delete;}; A f(){वापसी A(5);} A a=f(); अदालत
A
5 5
B
Compile error संकलन त्रुटि
C
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) C++17 mandatory elision doesn't require copy ctor. Output: 5.
व्याख्या (हिन्दी) C++17 अनिवार्य एलिज़न को कॉपी ctor की आवश्यकता नहीं है। आउटपुट: 5.
1708
EN + हिं
GB What is the output: class A{public:int x=0; ~A(){x=-1;} void print(){cout<x=5; p->print(); delete p; cout<x;
IN आउटपुट क्या है: class A{public:int x=0; ~A(){x=-1;} void print(){coutprint(); पी हटाएं; अदालत
A
5 then UB 5 फिर यूबी
B
Compile error संकलन त्रुटि
C
5-1 5-1
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) print()=5; after delete: p->x is UB. Output: 5 then UB.
व्याख्या (हिन्दी) प्रिंट()=5; हटाने के बाद: p->x UB है। आउटपुट: 5 फिर यूबी।
1709
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
123-3-2-1 123-3-2-1
B
123321 123321
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Constructed: 1,2,3. Destroyed reverse: -3,-2,-1. Output: 123-3-2-1.
व्याख्या (हिन्दी) निर्मित: 1,2,3. नष्ट उल्टा:-3,-2,-1. आउटपुट: 123-3-2-1.
1710
EN + हिं
1696–1710 of 1915