प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
In C++, struct A has void f(int) printing "A", and struct B : A declares only void f(double) printing "B". What does B b; b.f(1); print?
सही उत्तर: क) B
The f in B hides every f inherited from A (name hiding), so B::f(double) is called with 1 converted to 1.0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++, struct C has static int n = 0; its default constructor does n++ and its copy constructor does n += 10. What is C::n after C a; C b = a; ?
सही उत्तर: घ) 11
C a calls the default constructor (n = 1); C b = a calls the copy constructor (n = 11).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: string s = "Hello"; s.insert(5, " World"); cout << s.find('W'); ?
सही उत्तर: ग) 6
s becomes "Hello World"; 'W' is at index 6 (counting from 0).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++ (unlike C), what is the value of sizeof('A') on a system where int is 4 bytes?
सही उत्तर: ख) 1
In C++ a character literal has type char, so sizeof('A') is 1; in C it has type int.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: map<char, int> m; for (char c : string("banana")) m[c]++; cout << m['a'] << m.size(); ?
सही उत्तर: क) 33
'a' occurs 3 times, and the map has 3 distinct keys (a, b, n).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: vector<int> v = {5, 3, 8, 1}; sort(v.begin(), v.end()); cout << v[1] << v.back(); ?
सही उत्तर: घ) 38
After sorting, v = {1, 3, 5, 8}; v[1] = 3 and v.back() = 8.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++, B has a virtual destructor printing "B", and D : B has a destructor printing "D". What is printed by: B *p = new D; delete p; ?
सही उत्तर: ग) DB
Because the base destructor is virtual, the derived destructor runs first, then the base destructor: DB.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++, class A prints "1" in its constructor and "2" in its destructor. What is printed by main() { A *p = new A; delete p; A x; } ?
सही उत्तर: ख) 1212
new A prints 1, delete p prints 2, A x prints 1, and x is destroyed at the end of main printing 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: int a = 5; int &r = a; int b = r; b++; cout << a << b; ?
सही उत्तर: क) 56
b is an ordinary int copied from r (that is, from a), so incrementing b does not change a: 5 and 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
When a continue statement is executed inside a C do-while loop, control passes to:
सही उत्तर: घ) the evaluation of the loop condition
In a do-while loop, continue skips the rest of the body and jumps to the test of the while condition.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।