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

Question 1801

EN + हिं
GB What is the output: class A{int x=0; public:int get()const{return x;} void f(){x++;} void g(){f();f();f();}}; A a; a.g(); cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:int get()const{return x;} void f(){x++;} void g(){f();f();f();}}; ए ए; a.g(); अदालत
3 3
1 1
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) g() calls f() 3 times: x=3. Output: 3.
व्याख्या (हिन्दी) g() f() को 3 बार कॉल करता है: x=3। आउटपुट: 3.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1802

EN + हिं
GB What is the output: class A{int n; public:A(int v):n(v){} auto begin(){return &n;} auto end(){return &n+1;}}; A a(42); for(int x:a) cout<
IN आउटपुट क्या है: class A{int n; सार्वजनिक:ए(int v):n(v){} ऑटो प्रारंभ(){रिटर्न &n;} ऑटो एंड(){रिटर्न &n+1;}}; ए ए(42); for(int x:a) कोउट
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Iterates single element 42. Output: 42.
व्याख्या (हिन्दी) एकल तत्व को पुनरावृत्त करता है 42. आउटपुट: 42.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1803

EN + हिं
GB What is the output: class A{int x; public:A(int v):x(v){} int operator()(int y)const{return x*y;} int operator()(int y,int z)const{return x*(y+z);}}; A a(3); cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक:ए(int v):x(v){} int ऑपरेटर()(int y)const{रिटर्न x*y;} int ऑपरेटर()(int y,int z)const{रिटर्न x*(y+z);}}; ए ए(3); अदालत
1227 1227
Compile error संकलन त्रुटि
Undefined अपरिभाषित
12 27 12 27
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a(4)=3*4=12; a(4,5)=3*9=27. Output: 1227.
व्याख्या (हिन्दी) ए(4)=3*4=12; a(4,5)=3*9=27. आउटपुट: 1227.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1804

EN + हिं
GB What is the output: class A{int x=0; public:A& inc(){x++;return *this;} A& mul(int n){x*=n;return *this;} int val()const{return x;}}; A a; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:A& inc(){x++;return *this;} A& mul(int n){x*=n;return *this;} int val()const{return x;}}; ए ए; अदालत
9 9
3 3
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+1+1+1=3; 3*3=9. Output: 9.
व्याख्या (हिन्दी) 0+1+1+1=3; 3*3=9. आउटपुट: 9.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1805

EN + हिं
GB What is the output: class A{int x; public:explicit A(int v):x(v){} A operator-()const{return A(-x);} int get()const{return x;}}; A a(5); A b=-a; cout<
IN आउटपुट क्या है: class A{int x; सार्वजनिक:स्पष्ट A(int v):x(v){} A ऑपरेटर-()const{return A(-x);} int get()const{return x;}}; ए ए(5); ए बी=-ए; अदालत
-5 -5
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) -a: operator-() returns A(-5). b.get()=-5. Output: -5.
व्याख्या (हिन्दी) -ए: ऑपरेटर-() रिटर्न ए(-5)। बी.प्राप्त()=-5. आउटपुट:-5.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1806

EN + हिं
GB What is the output: class Stack{vectors; public:void push(int x){s.push_back(x);} int top()const{return s.back();} void pop(){s.pop_back();} bool empty()const{return s.empty();} int size()const{return s.size();}}; Stack st; st.push(1);st.push(2);st.push(3); cout<
IN आउटपुट क्या है: क्लास स्टैक {वेक्टर; सार्वजनिक: शून्य पुश (इंट एक्स) {एस पुश_बैक (एक्स); ढेर सेंट; st.push(1);st.push(2);st.push(3); अदालत
332 332
123 123
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) top=3,size=3; pop; top=2. Output: 332.
व्याख्या (हिन्दी) शीर्ष=3,आकार=3; जल्दी से आना; शीर्ष=2. आउटपुट: 332.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1807

EN + हिं
GB What is the output: class A{int x=0; public:void set(int v){x=v%10;} int get()const{return x;}}; A a; a.set(42); cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:शून्य सेट(int v){x=v%10;} int get()const{return x;}}; ए ए; ए.सेट(42); अदालत
2 2
42 42
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 42%10=2. Output: 2.
व्याख्या (हिन्दी) 42%10=2. आउटपुट: 2.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1808

EN + हिं
Compile error संकलन त्रुटि
8 8
5 5
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) max_element uses operator<, not >. Need operator<. Compile error if only operator> defined. Actually max_element uses operator< by default. Compile error.
व्याख्या (हिन्दी) max_element ऑपरेटर का उपयोग करता है। ऑपरेटर परिभाषित की आवश्यकता है. दरअसल max_element डिफ़ॉल्ट रूप से ऑपरेटर< का उपयोग करता है। संकलन त्रुटि.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1809

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<<1<<2<<3<<4<<5; cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:ए एवं ऑपरेटर
15 15
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+1+2+3+4+5=15. Output: 15.
व्याख्या (हिन्दी) 0+1+2+3+4+5=15. आउटपुट: 15.
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 1810

EN + हिं
GB What is the output: class A{int x; public:explicit A(int v):x(v){} int get()const{return x;} A& operator++(){++x;return *this;} A operator++(int){auto t=*this;++*this;return t;}}; A a(3); cout<<(a++).get()<
IN आउटपुट क्या है: class A{int x; सार्वजनिक:स्पष्ट A(int v):x(v){} int get()const{return x;} A& ऑपरेटर++(){++x;रिटर्न *यह;} A ऑपरेटर++(int){auto t=*this;++*this;रिटर्न t;}}; ए ए(3); अदालत
345 345
344 344
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a++=3(a=4); a.get()=4; ++a=5. Output: 345.
व्याख्या (हिन्दी) ए++=3(ए=4); a.get()=4; ++ए=5. आउटपुट: 345.
🎯 Exam Perspective
OOP Using C++ के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 1811

EN + हिं
GB What is the output: class A{string name_; public:A(string n):name_(n){} const string& name()const{return name_;} bool operator==(const A& o)const{return name_==o.name_;}}; A a("Bob"),b("Bob"),c("Alice"); cout<<(a==b)<<(a==c);
IN आउटपुट क्या है: क्लास ए{स्ट्रिंग नाम_; सार्वजनिक:ए(स्ट्रिंग एन):नाम_(एन){} स्थिरांक स्ट्रिंग&नाम()स्थिरांक{वापसी नाम_;} बूल ऑपरेटर==(स्थिरांक ए&ओ)स्थिरांक{वापसी नाम_==ओ.नाम_;}}; ए ए("बॉब"),बी("बॉब"),सी("ऐलिस"); अदालत
10 10
01 01
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Bob==Bob=1; Bob==Alice=0. Output: 10.
व्याख्या (हिन्दी) बॉब==बॉब=1; बॉब==ऐलिस=0. आउटपुट: 10.
🎯 Exam Perspective
यह सवाल OOP Using C++ category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 1812

EN + हिं
GB What is the output: class A{int n=0; public:void add(int x){n+=x;} void sub(int x){n-=x;} void neg(){n=-n;} int get()const{return n;}}; A a; a.add(5);a.add(3);a.neg();a.sub(2); cout<
IN आउटपुट क्या है: class A{int n=0; सार्वजनिक: शून्य जोड़ें (int x) {n + = x;} शून्य उप (int x) {n- = x;} शून्य नकारात्मक() {n = - n;} int get() स्थिरांक {वापसी n;}}; ए ए; a.add(5);a.add(3);a.neg();a.sub(2); अदालत
-10 -10
-8 -8
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0+5+3=8; neg=-8; -8-2=-10. Output: -10.
व्याख्या (हिन्दी) 0+5+3=8; नकारात्मक=-8; -8-2=-10. आउटपुट:-10.
🎯 Exam Perspective
यह प्रश्न OOP Using C++ की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 1813

EN + हिं
GB What is the output: class A{int x,y; public:A(int a,int b):x(a),y(b){} A scale(int n)const{return {x*n,y*n};} int mag2()const{return x*x+y*y;}}; A a(3,4); cout<
IN आउटपुट क्या है: class A{int x,y; सार्वजनिक:ए(int a,int b):x(a),y(b){} A स्केल(int n)const{return {x*n,y*n};} intmag2()const{return x*x+y*y;}}; ए ए(3,4); अदालत
100 100
25 25
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) scale(2)=(6,8); mag2=36+64=100. Output: 100.
व्याख्या (हिन्दी) स्केल(2)=(6,8); Mag2=36+64=100. आउटपुट: 100.
🎯 Exam Perspective
OOP Using C++ से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 1814

EN + हिं
GB What is the output: class A{int x=5; public:const int& cref()const{return x;} int& ref(){return x;}}; A a; a.ref()=10; cout<
IN आउटपुट क्या है: class A{int x=5; सार्वजनिक:const int& cref()const{return x;} int& ref(){return x;}}; ए ए; a.ref()=10; अदालत
10 10
5 5
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) ref()=x=10; cref()=10. Output: 10.
व्याख्या (हिन्दी) रेफरी()=x=10; क्रेफ़()=10. आउटपुट: 10.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में OOP Using C++ से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 1815

EN + हिं
GB What is the output: class Acc{double s=0,n=0; public:void add(double x){s+=x;n++;} double mean()const{return n?s/n:0;}}; Acc acc; acc.add(2);acc.add(4);acc.add(6); cout<
IN आउटपुट क्या है: class Acc{double s=0,n=0; सार्वजनिक:शून्य जोड़ें(डबल x){s+=x;n++;} डबल माध्य()const{रिटर्न n?s/n:0;}}; एसीसी एसीसी; acc.add(2);acc.add(4);acc.add(6); अदालत
4 4
6 6
Compile error संकलन त्रुटि
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) (2+4+6)/3=4. Output: 4.
व्याख्या (हिन्दी) (2+4+6)/3=4. आउटपुट: 4.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो OOP Using C++ का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।