Computer Knowledge

Programming Output Evaluation

1,721 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

Multiple choice general knowledge
  1. The output is always NO.

  2. The output is always ON.

  3. The output varies and is either NO or ON.

  4. The code does not compile.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The code calls worker.run() directly instead of worker.start(). Direct run() calls execute synchronously in the current thread, printing 'N' first, then 'O', resulting in 'NO'. No actual thread spawning occurs, so output is always deterministic.

Multiple choice general knowledge science & technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In the Joe editor (a lightweight text editor for Unix), the keyboard shortcut Ctrl+K followed by P moves the cursor to the top window when working with split windows. This is part of Joe's set of window management commands that allow users to navigate between multiple split panes efficiently. The Ctrl+K prefix activates Joe's command mode, and P is the specific command for positioning to the top window.

Multiple choice general knowledge science & technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In the Joe editor, the command to mark the end of a block (for text selection or blocking operations) is actually Ctrl+K followed by B, not Ctrl+K followed by L. Ctrl+K,B marks the beginning of a block and Ctrl+K,K marks the end of a block - this pair of commands is used to define a text block for operations like copying, moving, or deleting. The statement incorrectly claims that Ctrl+K,L is used for this purpose.

Multiple choice general knowledge science & technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In the vi editor, the command :qall (quit all) is used to close all buffers and exit the editor. This command is particularly useful when you have multiple files open simultaneously and want to close them all at once. It's different from :qa which also quits all, and :q! which quits the current window discarding changes. The :qall command will fail if any buffers have unsaved changes, requiring :qall! to force quit.

Multiple choice general knowledge
  1. Compiler error at line 1

  2. Compiler error at line 3

  3. Compiler error at line 4

  4. NullPointerException

  5. StringIndexOutOfBoundsException

  6. Prints “123null”

Reveal answer Fill a bubble to check yourself
F Correct answer
Explanation

When append(null) is called on a StringBuffer, it appends the string 'null'. Then insert(0, '123') inserts '123' at position 0. The result becomes '123null'. There's no NullPointerException because StringBuffer.append() handles null by converting it to the string 'null'. Option F correctly identifies this output.

Multiple choice general knowledge
  1. Does not compile

  2. Throws IllegalFormatConversionException

  3. Prints 222.46

  4. Prints 222.45

  5. Prints 2.224578

  6. Prints .2224578

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The format specifier '%.2f' rounds the double value to 2 decimal places. 222.4578 rounded to 2 decimal places is 222.46 (not 222.45, because the third decimal 7 causes rounding up). The printf method compiles and runs without error, printing the rounded value.

Multiple choice softskills creativity
  1. HP-UX-HewlettPack

  2. Error

  3. HP-UX_HewlettPack

  4. none

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

C function names cannot contain hyphens. The identifier OS_HP-UX_print is interpreted as OS_HP minus UX_print, which is invalid syntax. This causes a compilation error. Option A would be valid if the function were named OS_HP_UX_print with underscores. Hyphens are subtraction operators, not valid identifier characters.

Multiple choice softskills creativity
  1. 1243

  2. 4321

  3. 1234

  4. 4312

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

printf returns the number of characters printed. Working outward: innermost printf("%d",i) prints 43 and returns 2. Middle printf("%d",2) prints 2 and returns 1. Outermost printf("%d",1) prints 1 and returns 1. The printed characters appear left-to-right: 4321. Option B correctly shows this output.

Multiple choice softskills creativity
  1. Today is Aug 2, 201012

  2. Today is Aug 2, 2010

  3. Today is 12

  4. None

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The code formats the current date and appends the integer 12. If the date was Aug 2, 2010, the output 'Today is Aug 2, 201012' is produced because System.out.print does not add spaces or newlines between the date string and the integer.

Multiple choice softskills creativity
  1. 12

  2. nothing

  3. compilation error

  4. 0

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The code contains several errors: 'NowString()' is a constructor name that doesn't match the class 'NowS', and 'Super.Sam(12)' is invalid syntax for calling a superclass constructor (it should be 'super(12)'). These issues cause a compilation error.

Multiple choice technology programming languages
  1. Compilation Error - Undeclared Identifier

  2. Compilation Error - Syntax

  3. I dont know

  4. Will Compile but no Output

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

An empty function with just a semicolon is valid in C (as a null statement). While void main() is non-standard (standard C requires int main), many compilers accept it. The code compiles and runs, producing no output because there are no printf statements.