प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
In Java, class A { static String f() { return "A"; } } and class B extends A { static String f() { return "B"; } } are defined. What does A a = new B(); System.out.println(a.f()); print?
सही उत्तर: क) A
Static methods are hidden, not overridden; the call is resolved at compile time using the declared type A, so A.f() runs.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Java, class C { static int s = 0; int i = 0; C() { s++; i++; } } — after C p = new C(), q = new C(), r = new C(); what does System.out.println(r.s + "" + r.i); print?
सही उत्तर: घ) 31
The static field s is shared by all objects and reaches 3, while each object has its own i equal to 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Java fragment: System.out.println(String.valueOf(12).length() + Integer.toString(255, 16));
सही उत्तर: ग) 2ff
"12" has length 2, and 255 in base 16 is "ff"; int + String gives string concatenation, "2ff".
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Java fragment: int x = 10; x >>= 1; x ^= 3; System.out.println(x);
सही उत्तर: ख) 6
10 >> 1 = 5 (binary 101), and 101 XOR 011 = 110, which is 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Java fragment: int[] a = {1, 2, 3}; int s = 0; for (int x : a) s += x * x; System.out.println(s);
सही उत्तर: क) 14
The enhanced for loop adds the squares 1 + 4 + 9 = 14.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: cout << fixed << setprecision(2) << 10.0 / 3;
सही उत्तर: घ) 3.33
fixed with setprecision(2) prints exactly two digits after the decimal point: 3.33.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: string a = "10", b = "9"; cout << (a < b) << (stoi(a) < stoi(b));
सही उत्तर: ग) 10
Strings compare character by character, and '1' < '9', so "10" < "9" is true (1); as integers 10 < 9 is false (0).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: try { try { throw 1; } catch (int e) { cout << e; throw; } } catch (...) { cout << "X"; }
सही उत्तर: ख) 1X
The inner handler prints 1 and then 'throw;' rethrows the same exception, which the outer catch (...) handles by printing X.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this C++ fragment: vector<int> v{3, 6, 9, 12}; cout << (find(v.begin(), v.end(), 9) - v.begin()) << accumulate(v.begin(), v.end(), 0);
सही उत्तर: क) 230
find returns an iterator to 9, which is 2 positions from begin; accumulate adds 3 + 6 + 9 + 12 = 30.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Given template <class T> string t(T) { return "G"; } and the specialisation template <> string t(int) { return "I"; }, what is printed by cout << t(1.5) << t(2); ?
सही उत्तर: घ) GI
t(1.5) uses the general template with T = double, while t(2) matches the explicit specialisation for int.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।