Computer Knowledge
Programming Output Evaluation
1,953 Questions
Programming output evaluation tests the ability to trace code execution in languages like C, Java, and SAS. It focuses on arrays, loops, pointers, and data type conversions. These technical questions are standard in computer knowledge sections for IT officer and bank exams.
Java string bufferC language pointersLoop execution outputsData type conversionsMacro variable evaluation
Programming Output Evaluation Questions
-
Compilation Error
-
Runtime error
-
Nothing will be printed as output
-
5
D
Correct answer
Explanation
Variables declared with the 'var' keyword in JavaScript are function-scoped rather than block-scoped. Because 'var a' is declared inside the function 'geek', it is accessible anywhere within that function, even outside the 'if' block where it was defined.
-
Floating point numbers between 0 and 3.
-
Integers between 0 and 2.
-
Integers between 0 and 3.
-
Doubles from 0 to 3, including 0 but not including 3.
B
Correct answer
Explanation
Math.random() returns a double value greater than or equal to 0.0 and strictly less than 1.0. Multiplying this by 3 yields a value in the range [0.0, 3.0), and casting this result to an integer truncates the decimal portion, resulting in the integers 0, 1, or 2.
-
public static final void foo;
-
public static final int USERS = 20;
-
public FINAL SIZE = 10;
-
public static boolean final BORED = TRUE;
B
Correct answer
Explanation
A valid constant declaration in Java requires a visibility modifier, the static and final keywords, a data type, an identifier, and an initial value. Option B correctly follows this structure: 'public static final int USERS = 20;'. Option D is incorrect because 'final' must precede the data type, and 'TRUE' is not a valid boolean literal.