प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
In Java, compiling the statements char c = 'A'; c = c + 1; results in:
सही उत्तर: ख) a compile-time error: possible lossy conversion from int to char
c + 1 has type int, and assigning it to a char needs an explicit cast; (c += 1 would compile because compound assignment casts automatically).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Java, what is printed by: String s = "Nepal"; System.out.println(s.length() + s.indexOf('p')); ?
सही उत्तर: क) 7
length() is 5 and indexOf('p') is 2; both are ints, so they are added: 7.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Java, what is printed by: int[] a = {3, 1, 2}; java.util.Arrays.sort(a); System.out.println(a[0] + "" + a[2]); ?
सही उत्तर: घ) 13
After sorting a = {1, 2, 3}; a[0] + "" + a[2] concatenates 1 and 3 into "13".
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Mixing strings and arithmetic in Java, the statement System.out.println("5" + 3 * 2); outputs:
सही उत्तर: ग) 56
* is evaluated first (3 * 2 = 6), then "5" + 6 performs string concatenation: 56.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++, a class that contains at least one pure virtual function is called a/an:
सही उत्तर: ग) abstract class
A class with a pure virtual function is abstract: objects of it cannot be created, but it can be used as a base class.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: string s = "abc"; reverse(s.begin(), s.end()); cout << s; ?
सही उत्तर: ख) cba
std::reverse reverses the characters of the string in place.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++, struct S { int v; S(int x) : v(x) {} bool operator<(const S &o) const { return v > o.v; } };. What is printed by S a(3), b(7); cout << (a < b); ?
सही उत्तर: क) 0
The overloaded < actually returns v > o.v, i.e. 3 > 7, which is false and prints as 0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In C++, class Box has a constructor Box(int x = 2) : w(x) {} and int get() const { return w; }. What is printed by Box a, b(5); cout << a.get() + b.get(); ?
सही उत्तर: घ) 7
a uses the default argument (w = 2) and b has w = 5, so 2 + 5 = 7.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: int a[] = {1, 2, 3, 4}; int s = 0; for (int &x : a) { x *= 2; s += x; } cout << s << a[3]; ?
सही उत्तर: ग) 208
Through the reference each element is doubled to {2, 4, 6, 8}; s = 20 and a[3] = 8, printed as 208.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C++ code: stack<int> s; s.push(1); s.push(2); s.push(3); s.pop(); cout << s.top() << s.size(); ?
सही उत्तर: ख) 22
After popping 3, the top is 2 and two elements remain.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।