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

Question 106

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

Question 107

EN + हिं
GB What is the output: class A{int x=0; public:void f(){x+=2;} void g(){f();f();} void h(){g();g();} int get()const{return x;}}; A a; a.h(); cout<
IN आउटपुट क्या है: class A{int x=0; सार्वजनिक:void f(){x+=2;} void g(){f();f();} void h(){g();g();} int get()const{return x;}}; ए ए; ए.एच(); अदालत
8 8
4 4
Compile error Compile error
Undefined Undefined
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) h: g,g. g: f,f. Each f: x+=2. 4 calls: x=8. Output: 8.
व्याख्या (हिन्दी) एच: जी, जी. जी: एफ,एफ। प्रत्येक f: x+=2. 4 कॉल: x=8. आउटपुट: 8.
🎯 Exam Perspective
यह सवाल OOP Using C++ ("Encapsulation" sub-topic) category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।