प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
What is the output of the Python code: d = {'a': 1, 'b': 2}; print(list(d.items())[1]) ?
सही उत्तर: घ) ('b', 2)
items() yields key-value tuples in insertion order; index 1 is ('b', 2).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: s = {1, 2, 3}; s.add(2); s.add(4); print(len(s)) ?
सही उत्तर: ग) 4
Adding 2 again has no effect because sets hold unique elements; adding 4 gives {1, 2, 3, 4}.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print('Nepal'.ljust(7, '*')) ?
सही उत्तर: ख) Nepal**
ljust(7, '*') left-justifies the string in a field of width 7, filling the remaining 2 places on the right with '*'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Using split() with a maximum split count in Python, what does print('a-b-c'.split('-', 1)) display?
सही उत्तर: क) ['a', 'b-c']
The second argument maxsplit = 1 allows only one split, at the first '-', giving ['a', 'b-c'].
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Consider the Java statements int x = 10; x = x++ + x--; followed by printing x. Which value is shown?
सही उत्तर: घ) 21
x++ yields 10 (x becomes 11), x-- yields 11 (x becomes 10), and the sum 21 is then assigned to x. Java evaluates operands left to right.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In a Java class with the overloads static void f(long x) and static void f(Integer x), each printing its parameter type, what does the call f(5) print?
सही उत्तर: ग) long
Java prefers widening a primitive (int to long) over boxing (int to Integer), so f(long) is chosen.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Java, what is printed by: int[][] m = new int[3][4]; System.out.println(m.length + " " + m[0].length); ?
सही उत्तर: ख) 3 4
m.length is the number of rows (3) and m[0].length is the number of columns in a row (4).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Java evaluates System.out.println(1 / 2.0 + 1 / 2); and displays which value?
सही उत्तर: क) 0.5
1 / 2.0 = 0.5 (floating point) and 1 / 2 = 0 (integer division), so 0.5 + 0 = 0.5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Java, what is printed by: long x = Integer.MAX_VALUE; x++; System.out.println(x); ?
सही उत्तर: घ) 2147483648
x is a long, so incrementing 2147483647 does not overflow and gives 2147483648.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Java, what is printed by: String a = "Hi"; String b = new String("Hi"); System.out.println((a == b) + " " + a.equals(b)); ?
सही उत्तर: ग) false true
new String creates a separate object, so == (reference comparison) is false, while equals() compares contents and is true.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।