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. Compilation error: Incompatible types

  2. This is false

  3. This is true

  4. Runtime exception

  5. None of these

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

b=d is not a comparison but d’s value is assigned to b, and returns true and a++<=c will result true too. “This is true” will be printed.

Multiple choice
  1. Infinite loop

  2. Syntax error

  3. Value is not initialized here

  4. 24681012141618

  5. 1820

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

Test expression not specified at right place, still the for loop wont execute even once But j++ would yield 0 as j’s read value will be 0, after which it is incremented.

Multiple choice
  1. a=0, x=10, y=20, z=30

  2. a=1, x=30, y=50, z=30

  3. a=0, x=30, y=50, z=30

  4. a=1, x=30, y=20, z=30

  5. a=1, x=10, y=50, z=30

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

X+=y gives 30, which is a non zero value and logical or operator returns 1, when there is atleast one non zero value. Thus retrieving a non zero value already terminates before calculating y+=z.

Multiple choice
  1. Compilation error: switch selection expression must be of integral type

  2. Hello

  3. Compilation error: constant expression required

  4. Compilation error: duplicate case

  5. Options 1,3 and 4

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

All the three errors occurred.

Multiple choice
  1. public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 31 * h + val[i]; } } return h; }

  2. public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 27 * h + val[i]; } } return h; }

  3. public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 131 * h + val[i]; } } return h; }

  4. public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 231 * h + val[i]; } } return h; }

  5. public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 531 * h + val[i]; } } return h; }

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

31 is used because 31 * i == (i << 5) - i. This can be performed very quickly.