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
  1. 2 2

  2. 2 4

  3. 4 4

  4. Null

  5. It will not compile.

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

The method in the class Demo1 will be called twice, as new keyword is used for method hiding of the child class.

Multiple choice
  1. Compilation error due to invalid cast of Object to String.

  2. Compilation error due to invalid cast of String to Object.

  3. Welcome

  4. Null

  5. Exception is possible.

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

Correct output as it is a valid conversion for Object class.

Multiple choice
  1. GATE2011

  2. E2011

  3. 2011

  4. 011

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

The pointer p points to 'G' (index 0). p[3] = 'E' (ASCII 69) and p[1] = 'A' (ASCII 65). So p[3] - p[1] = 69 - 65 = 4. Therefore p + 4 points to index 4, which is '2'. printf(%s, p+4) prints from '2' onward: '2011'. The key is pointer arithmetic with character ASCII values.

Multiple choice
  1. No choice

  2. Choice A

  3. Choice A, Choice B No choice

  4. Program gives no output as it is erroneous

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

Since there is no ‘break’ statement, the program executes all the subsequent case statements after printing “choice A”

Multiple choice
  1. 3 1 4 1 4 2

  2. 4 2 6 1 6 1

  3. 4 2 6 2 2 0

  4. 4 2 4 2 2 0

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

Static local variables: Scope is limited to function/block but life time is entire program. Automatic local variables: Storage allocated on function entry and automatically deleted or freed when the function is exited. Register variables: Same as automatic variables except that the register variables will not have addresses. Hence, may not take the address of a register variable.

Multiple choice
  1. mask $\leftarrow$ 0 ×l << pos
  2. musk $\leftarrow$ 0 × ffffffff >> pos
  3. mask $\leftarrow$pos
  4. masdk $\leftarrow$0×f
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Multiple choice
  1. S1

  2. S2 and S3

  3. S2 and S4

  4. S2 and S5

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