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

Multiple choice
  1. u0000

  2. 0

  3. null

  4. 0.0f

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

The default value for char primitive type in Java is '\u0000' (the null character). This is Unicode value 0. Option B (0) is an int, C (null) is only for reference types, and D (0.0f) is for float.

Multiple choice
  1. 012345

  2. Compile time error

  3. Code will not produce output

  4. It will show error in Object o=i; and in for(int i3:i2)

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

This code demonstrates array type covariance and casting. An int array can be assigned to an Object reference, then cast back to int array. The for-each loop prints 012345. No errors occur.

Multiple choice
  1. Compile error

  2. 10

  3. Run time error

  4. Zero

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

The code creates an ArrayList, adds 10, retrieves index 0, and prints it. This compiles and runs successfully, outputting 10. ArrayList stores Integer objects; get() returns an Integer which is auto-unboxed to int. No compilation or runtime errors occur.

Multiple choice
  1. Run time error

  2. Compile time error

  3. 12345

  4. hello

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

The String.valueOf() method converts the integer 12345 to its string representation "12345". The original string "hello" is overwritten when str is reassigned. The output is simply the string "12345" printed to console.

Multiple choice
  1. Run time error

  2. Compile time error

  3. C=3

  4. Garbage value

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

The code performs simple integer addition: a=1, b=2, so c=a+b equals 3. The println statement concatenates "C=" with the value of c (3), producing "C=3" as output. There are no compilation or runtime errors.

Multiple choice
  1. Compile time error

  2. Run time error

  3. 99.000000000000

  4. 99

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

A long value (99L) is explicitly cast to an int using (int) bvalue. Since 99 fits within the range of int (-2^31 to 2^31-1), the cast succeeds without data loss. The output is simply 99, not 99.0 or any decimal representation.

Multiple choice
  1. The result is 35.

  2. The result is 47.

  3. The result is 45.

  4. The result is 35.

  5. There is error in the program.

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

The correct answer is 45.

Multiple choice
  1. Program will find the sum of digits.

  2. Program will find the number of digits.

  3. Invalid

  4. Program will run infinite times.

  5. There will be error in the program.

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

This option is correct.