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 technology programming languages
  1. Does not compile

  2. Throws IllegalFormatConversionException

  3. Prints 222.46

  4. Prints 222.45

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

The syntax System.out.printf("% .2f", d) uses a space flag, which prefixes positive numbers with a space, and .2 specifying two decimal places. The double value 222.4578 is formatted and rounded to two decimal places, outputting 222.46 (with a leading space), meaning it compiles and prints 222.46.

Multiple choice technology programming languages
  1. Compiler error

  2. FileNotFoundException thrown at line 1

  3. IOException thrown at line 2

  4. None of these

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

FileWriter creates the file if it doesn't exist, so no FileNotFoundException is thrown. The code compiles without errors and runs successfully. The write(1) call writes the character representation of integer 1, not the binary value. All options A, B, and C are incorrect because no compiler error, no FileNotFoundException at line 1, and no IOException at line 2 occur.

Multiple choice technology programming languages
  1. 5,4

  2. -4,4

  3. -5,4

  4. -4,5

  5. Compilation Error

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

The post-decrement operator a-- returns the original value of a (which is 5) and then decrements a to 4. Thus, num = -5. The printf statement outputs num followed by a, resulting in -5 4.

Multiple choice technology programming languages
  1. CompilationFails

  2. Will Throw RunTime Error But Code will get Compiled

  3. Throws Linker Error

  4. All the above statements are invalid

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

sizeof(void) is invalid in C and C++ - void is an incomplete type with no defined size. The malloc call will fail to compile because you cannot determine the size of void.

Multiple choice technology programming languages
  1. 5,4

  2. -4,4

  3. -5,4

  4. -4,5

  5. Compilation Error

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

The post-decrement operator a-- evaluates to the current value of a (which is 5) before decrementing a to 4. Therefore, num is assigned -5. The final values printed for num and a are -5 and 4, matching the marked choice.