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 general knowledge
  1. p1

  2. p2

  3. empty string

  4. name

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

The while loop copies 'name' to p2 but both p1 and p2 are incremented after each assignment. When the loop exits, p2 points to the null terminator, so printf(%s, p2) prints an empty string. The key is understanding post-increment behavior.

Multiple choice general knowledge
  1. p1

  2. p2

  3. empty string

  4. name

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

This is identical to question 82605. The while loop copies 'name' to p2 but both p1 and p2 are incremented after each assignment. When the loop exits, p2 points to the null terminator, so printf(%s, p2) prints an empty string.

Multiple choice general knowledge science & technology
  1. 2,2

  2. 1,3

  3. 2,3

  4. 1,2

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

++i is pre-increment (increments first, then returns new value), so i becomes 2 and prints 2. i++ is post-increment (returns current value, then increments), so it prints 2 again (current value) then increments to 3. Output: 2,2. Note: void main() is non-standard but works in some compilers.

Multiple choice general knowledge history
  1. i=0

  2. i=11

  3. Invalid argument to operation

  4. None

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

The statement 'System.out.println("i="+++i);' contains a syntax error. The '++' is the pre-increment operator, but the expression '+++i' (which could be parsed as '++ + +i' or similar) is invalid Java syntax. In Java, you cannot have three plus signs in a row like this - it's ambiguous and the compiler will reject it.

Multiple choice general knowledge history
  1. 10 & 12

  2. 10 & 10

  3. Compile Time Error

  4. None

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

The code int x=y=10; attempts to declare variables x and y and assign them values in a single statement. In Java, this syntax is invalid because y is being used before it has been declared - you cannot chain variable declarations like this when the first variable doesn't exist yet. The correct way would be int y=10, x=y; or declare them separately. Therefore, a compile-time error occurs.

Multiple choice general knowledge history
  1. i | j = 3

  2. i | j = 2

  3. Compile Time Error

  4. None

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

The bitwise OR operation i|j compares each bit of i (binary 11 = decimal 3) and j (binary 10 = decimal 2). Bitwise OR produces 1 if at least one operand has a 1 in that position. So: 11 | 10 = 11 (binary) which equals 3 in decimal. The output is i|j=3.

Multiple choice general knowledge history
  1. X=8

  2. X=10

  3. X=11

  4. None

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

In Java (and several other programming languages), integer literals starting with 0 are interpreted as octal (base-8) numbers, not decimal. The literal '010' in octal equals 8 in decimal (1×8¹ + 0×8⁰ = 8). Therefore, when the code prints 'X=' + x, it outputs 'X=8'. This is a common trick question testing knowledge of octal notation in programming languages.