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
151
EN + हिं
GB What is the output: int f(int n){ return n?n+f(n-1):0; } cout<
IN आउटपुट क्या है: int f(int n){ return n?n+f(n-1):0; } कोउट
A
10 10
B
4 4
C
24 24
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(4)=4+f(3)=4+3+f(2)=4+3+2+f(1)=4+3+2+1+f(0)=4+3+2+1+0=10.
व्याख्या (हिन्दी) f(4)=4+f(3)=4+3+f(2)=4+3+2+f(1)=4+3+2+1+f(0)=4+3+2+1+0=10.
152
EN + हिं
GB What is 'memoization' in the context of recursive functions?
IN पुनरावर्ती कार्यों के संदर्भ में 'संस्मरण' क्या है?
A
Caching results of function calls फ़ंक्शन कॉल के कैशिंग परिणाम
B
Memory optimization technique मेमोरी अनुकूलन तकनीक
C
Using static variables स्थैतिक चर का उपयोग करना
D
Tail call optimization टेल कॉल अनुकूलन
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Memoization stores the results of expensive function calls and returns cached results when the same inputs occur again.
व्याख्या (हिन्दी) मेमोइज़ेशन महंगे फ़ंक्शन कॉल के परिणामों को संग्रहीत करता है और समान इनपुट दोबारा होने पर कैश्ड परिणाम लौटाता है।
153
EN + हिं
GB What is the output: int x=10; auto f=[&](){ return ++x; }; cout<
IN आउटपुट क्या है: int x=10; ऑटो f=[&](){वापसी++x; }; अदालत
A
1112 1112
B
Unspecified अनिर्दिष्ट
C
1112 1112
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Order of evaluation of arguments to << is unspecified before C++17; both calls modify x but print order is unspecified.
व्याख्या (हिन्दी) तर्कों के मूल्यांकन का क्रम
154
EN + हिं
GB What is 'noexcept' specifier in C++?
IN C++ में 'noexcept' विनिर्देशक क्या है?
A
Guarantees function throws no exceptions गारंटी फ़ंक्शन कोई अपवाद नहीं देता है
B
Prevents exception handling अपवाद प्रबंधन को रोकता है
C
Makes function constexpr फ़ंक्शन कॉन्स्टेक्सपीआर बनाता है
D
Catches all exceptions सभी अपवादों को पकड़ता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) noexcept declares that a function will not throw exceptions; if it does, std::terminate is called.
व्याख्या (हिन्दी) noexcept घोषित करता है कि कोई फ़ंक्शन अपवाद नहीं फेंकेगा; यदि ऐसा होता है, तो std::terminet को कॉल किया जाता है।
155
EN + हिं
GB What is the output: int f(int x, int y=x){ return x+y; }
IN आउटपुट क्या है: int f(int x, int y=x){ return x+y; }
A
Works in C++17 C++17 में काम करता है
B
Compile error संकलन त्रुटि
C
Undefined behavior अपरिभाषित व्यवहार
D
Works if x is const यदि x स्थिरांक है तो काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Default argument cannot refer to another parameter; this is a compile error.
व्याख्या (हिन्दी) डिफ़ॉल्ट तर्क किसी अन्य पैरामीटर को संदर्भित नहीं कर सकता; यह एक संकलन त्रुटि है.
156
EN + हिं
GB What is the output: void f(int* p){ *p=20; } int a=10; f(&a); cout<
IN आउटपुट क्या है: void f(int* p){ *p=20; } int a=10; एफ(&ए); अदालत
A
10 10
B
20 20
C
Undefined अपरिभाषित
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f takes pointer to int, dereferences and sets to 20, modifying a. Output: 20.
व्याख्या (हिन्दी) f पॉइंटर को int, dereferences पर ले जाता है और a को संशोधित करते हुए 20 पर सेट करता है। आउटपुट: 20.
157
EN + हिं
GB What is the output: int f(int n){ return n>0?f(n/2)+1:0; } cout<
IN आउटपुट क्या है: int f(int n){ return n>0?f(n/2)+1:0; } कोउट
A
3 3
B
4 4
C
8 8
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) f(8)=f(4)+1=f(2)+2=f(1)+3=f(0)+4=0+4=4. Wait: f(8)=f(4)+1; f(4)=f(2)+1; f(2)=f(1)+1; f(1)=f(0)+1=1; f(2)=2; f(4)=3; f(8)=4. Answer: 4.
व्याख्या (हिन्दी) f(8)=f(4)+1=f(2)+2=f(1)+3=f(0)+4=0+4=4. रुको: f(8)=f(4)+1; f(4)=f(2)+1; f(2)=f(1)+1; f(1)=f(0)+1=1; एफ(2)=2; एफ(4)=3; एफ(8)=4. उत्तर: 4.
158
EN + हिं
GB What is 'function template argument deduction'?
IN 'फ़ंक्शन टेम्प्लेट तर्क कटौती' क्या है?
A
Compiler deducing template args from function arguments कंपाइलर फ़ंक्शन तर्कों से टेम्प्लेट तर्क निकालता है
B
Manually specifying template arguments टेम्पलेट तर्कों को मैन्युअल रूप से निर्दिष्ट करना
C
Runtime type deduction रनटाइम प्रकार की कटौती
D
Only works with auto केवल ऑटो के साथ काम करता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) When calling a function template, the compiler deduces template type parameters from the types of the provided arguments.
व्याख्या (हिन्दी) फ़ंक्शन टेम्प्लेट को कॉल करते समय, कंपाइलर प्रदान किए गए तर्कों के प्रकारों से टेम्प्लेट प्रकार के पैरामीटर निकालता है।
159
EN + हिं
GB What is the output: int f(int x){ return x; } double f(double x){ return x; } cout<
IN आउटपुट क्या है: int f(int x){ return x; } डबल एफ (डबल एक्स) { रिटर्न एक्स; } कोउट
A
1 1
B
1.0 1.0
C
Ambiguous अस्पष्ट
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 1 is int literal; exact match to f(int). Output: 1.
व्याख्या (हिन्दी) 1 पूर्णांक शाब्दिक है; f(int) से सटीक मिलान। आउटपुट: 1.
160
EN + हिं
GB What is the output: auto f=[]()mutable{ static int x=0; return x++; }; cout<
IN आउटपुट क्या है: auto f=[]()mutable{static int x=0; वापसी x++; }; अदालत
A
012 012
B
000 000
C
Unspecified अनिर्दिष्ट
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Order of evaluation of arguments to << is unspecified, so print order of 0,1,2 is unspecified.
व्याख्या (हिन्दी) तर्कों के मूल्यांकन का क्रम
161
EN + हिं
GB What is the output: int a[]={1,2,3}; int *p=a; cout<<*(p+2);
IN आउटपुट क्या है: int a[]={1,2,3}; int *p=a; अदालत
A
3 3
B
2 2
C
1 1
D
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) p+2 points to a[2]=3.
व्याख्या (हिन्दी) p+2 a[2]=3 की ओर इंगित करता है।
162
EN + हिं
GB What is the output: int a[3][2]={{1,2},{3,4},{5,6}}; cout<
IN What is the output: int a[3][2]={{1,2},{3,4},{5,6}}; अदालत
A
4 4
B
3 3
C
2 2
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) a[1][1] is row 1, col 1 = 4.
व्याख्या (हिन्दी) a[1][1] पंक्ति 1 है, कॉलम 1 = 4।
163
EN + हिं
GB What is the size of: int arr[10]; cout<
IN What is the size of: int arr[10]; अदालत
A
10 10
B
40 40
C
8 8
D
Compile error संकलन त्रुटि
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sizeof(arr)=10*sizeof(int)=10*4=40 on most platforms.
व्याख्या (हिन्दी) अधिकांश प्लेटफ़ॉर्म पर sizeof(arr)=10*sizeof(int)=10*4=40।
164
EN + हिं
GB What is the output: int a[5]={1}; cout<
IN What is the output: int a[5]={1}; अदालत
A
1 1
C
Undefined अपरिभाषित
D
Garbage कचरा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Partial initialization zero-fills remaining elements: a[4]=0.
व्याख्या (हिन्दी) आंशिक आरंभीकरण शून्य-शेष तत्वों को भरता है: a[4]=0।
165
EN + हिं
GB What is the output: int a[]={1,2,3}; cout<
IN आउटपुट क्या है: int a[]={1,2,3}; अदालत
A
1 1
B
3 3
C
4 4
D
12 12
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) sizeof(a)=12, sizeof(a[0])=4. 12/4=3 (array length).
व्याख्या (हिन्दी) आकार(ए)=12, आकार(ए[0])=4. 12/4=3 (सरणी लंबाई)।
151–165 of 1915