OOP Using C++ — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye

📚 163 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
163 questions
31
EN + हिं
GB What is the output: int x = -5; cout << (x >> 1);
IN आउटपुट क्या है: int x = -5; कॉउट > 1);
A
-3 -3
B
-2 -2
C
-1 -1
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Right-shifting a negative signed integer is implementation-defined. On most platforms (arithmetic shift): -5>>1 = -3 (rounds toward negative infinity).
व्याख्या (हिन्दी) एक नकारात्मक हस्ताक्षरित पूर्णांक को राइट-शिफ्टिंग कार्यान्वयन-परिभाषित है। अधिकांश प्लेटफ़ॉर्म पर (अंकगणितीय बदलाव): -5>>1 = -3 (नकारात्मक अनंत की ओर राउंड)।
32
EN + हिं
GB What is the output: int a=3,b=4; if(a=0) cout<
IN आउटपुट क्या है: int a=3,b=4; if(a=0) cout
A
3 3
B
4 4
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a=0 assigns 0 to a (evaluates to 0 = false), so else branch executes printing b=4.
व्याख्या (हिन्दी) a=0, a को 0 निर्दिष्ट करता है (0 = गलत का मूल्यांकन करता है), इसलिए अन्यथा शाखा b=4 मुद्रण निष्पादित करती है।
33
EN + हिं
GB What is the output: int x=5; cout<<(x&1?'O':'E');
IN आउटपुट क्या है: int x=5; अदालत
A
O हे
B
E
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5&1=1: odd. Output: O.
व्याख्या (हिन्दी) 5&1=1: विषम। आउटपुट: ओ.
34
EN + हिं
GB What is the output: int x=12; cout<<(x&(x-1));
IN आउटपुट क्या है: int x=12; अदालत
A
8 8
B
12 12
C
4 4
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 12=1100, 11=1011. AND=1000=8. Output: 8.
व्याख्या (हिन्दी) 12=1100, 11=1011. तथा=1000=8. आउटपुट: 8.
35
EN + हिं
GB What is the output: cout<<(true?1:2.0);
IN आउटपुट क्या है: cout
A
1 1
B
1.0 1.0
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Common type is double. Returns 1.0. Output: 1.
व्याख्या (हिन्दी) सामान्य प्रकार डबल है। रिटर्न 1.0. आउटपुट: 1.
36
EN + हिं
GB What is the output: int x=5; cout<<(!x)<<(!!x)<<(!!!x);
IN आउटपुट क्या है: int x=5; अदालत
A
010 010
B
101 101
C
001 001
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) !5=0, !!5=1, !!!5=0. Output: 010.
व्याख्या (हिन्दी) !5=0, !!5=1, !!!5=0. आउटपुट: 010.
37
EN + हिं
GB What is the output: int a=6,b=3; cout<<(a/=b,a*=b,a);
IN आउटपुट क्या है: int a=6,b=3; अदालत
A
6 6
B
2 2
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a/=3=2, a*=3=6, return a=6. Output: 6.
व्याख्या (हिन्दी) a/=3=2, a*=3=6, वापसी a=6। आउटपुट: 6.
38
EN + हिं
GB What is 'conditional assignment' idiom?
IN 'सशर्त असाइनमेंट' मुहावरा क्या है?
A
x = cond ? a : b; assign based on condition एक्स = शर्त? ए : बी; शर्त के आधार पर असाइन करें
B
Same as if-else यदि-अन्यथा के समान
C
Short-circuit assignment शॉर्ट-सर्किट असाइनमेंट
D
Macro pattern मैक्रो पैटर्न
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Ternary for assignment: x=(n>0)?n:0 is concise conditional assignment.
व्याख्या (हिन्दी) असाइनमेंट के लिए टर्नरी: x=(n>0)?n:0 संक्षिप्त सशर्त असाइनमेंट है।
39
EN + हिं
GB What is the output: int x=0xFF; cout<<(x^=0x0F);
IN आउटपुट क्या है: int x=0xFF; अदालत
A
240 240
B
255 255
C
15 15
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0xFF^0x0F=0xF0=240. Output: 240.
व्याख्या (हिन्दी) 0xFF^0x0F=0xF0=240. आउटपुट: 240.
40
EN + हिं
GB What is the output: int x=5; cout<<(x<<0);
IN आउटपुट क्या है: int x=5; अदालत
A
5 5
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Shift by 0 = no change. Output: 5.
व्याख्या (हिन्दी) 0 से शिफ्ट = कोई परिवर्तन नहीं। आउटपुट: 5.
41
EN + हिं
GB What is the output: int x=5; cout<<(x>3&&x<10);
IN आउटपुट क्या है: int x=5; अदालत
A
1 1
C
Compile error संकलन त्रुटि
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5>3=true, 5<10=true. true&&true=1. Output: 1.
व्याख्या (हिन्दी) 5>3=सत्य, 5
42
EN + हिं
GB What is 'safe bool idiom'?
IN 'सुरक्षित बूल मुहावरा' क्या है?
A
Explicit operator bool to prevent implicit numeric conversions अंतर्निहित संख्यात्मक रूपांतरणों को रोकने के लिए स्पष्ट ऑपरेटर बूल
B
A macro एक मैक्रो
C
A template एक टेम्पलेट
D
A design pattern एक डिज़ाइन पैटर्न
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) explicit operator bool() on smart pointers prevents accidental arithmetic like ptr+1.
व्याख्या (हिन्दी) स्मार्ट पॉइंटर्स पर स्पष्ट ऑपरेटर बूल() पीटीआर+1 जैसे आकस्मिक अंकगणित को रोकता है।
43
EN + हिं
GB What is the output: int x=5; auto r=x>3?++x: (1, 6, 73, 3, 4, 'What is the output: int x=8; while(x&(x-1)) x&=x-1; cout<
IN आउटपुट क्या है: int x=5; ऑटो r=x>3?++x: (1, 6, 73, 3, 4, 'आउटपुट क्या है: int x=8; while(x&(x-1)) x&=x-1; cout
A
2026-05-25 2026-05-25
✅ Correct Answer:
44
EN + हिं
GB What is the output: int x=8; while(x&(x-1)) x&=x-1; cout<
IN आउटपुट क्या है: int x=8; जबकि(x&(x-1)) x&=x-1; अदालत
A
8 8
B
4 4
C
1 1
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 8=1000 is already power of 2. 8&7=0: loop doesn't execute. Output: 8.
व्याख्या (हिन्दी) 8=1000 पहले से ही 2 की शक्ति है। 8&7=0: लूप निष्पादित नहीं होता है। आउटपुट: 8.
45
EN + हिं
GB What is the output: int x=0; cout<<(x=5,x*x);
IN आउटपुट क्या है: int x=0; अदालत
A
25 25
B
5 5
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Evaluates x=5, then x*x=25. Output: 25.
व्याख्या (हिन्दी) x=5 का मूल्यांकन करता है, फिर x*x=25. आउटपुट: 25.
31–45 of 163