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

  2. 2

  3. 3

  4. nullpointer assignment

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

Tracing the pointers: abc.next points to def, def.next points to ghi, ghi.prev points back to def, def.next points to ghi, and ghi.i equals 2. The entire expression evaluates to 2. Option A (1) would be def.i, and Option C (3) would be jkl.i.

Multiple choice technology programming languages
  1. compile time error

  2. run time error

  3. p is initialized to 87

  4. space for an array of 87 integers is allocated

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

In C++, new int(87) allocates memory for a single int and initializes it to 87. The pointer p points to this allocated int containing value 87. Option D would require new int[87](array syntax).

Multiple choice technology programming languages
  1. c++

  2. c

  3. Compile time error

  4. None of these

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

Float 0.7 is stored as 0.699999... due to binary representation. Literal 0.7 in the if condition becomes double (more precise). Comparison: 0.699999 < 0.700000 → true, so c++ prints. This demonstrates floating-point precision issues.

Multiple choice technology programming languages
  1. 0

  2. Garbage value

  3. Compile time error

  4. 1

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

In C, local variables (including those declared with the register storage class) are not automatically initialized. Reading an uninitialized local variable results in undefined behavior, which typically prints whatever garbage value happens to be in that register or memory location.

Multiple choice technology programming languages
  1. Compilation and output of the value 0

  2. Compile time error because i has not been initialized

  3. Compilation and output of null

  4. Compile time error

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

Java does not allow static variables to be declared inside methods - static variables must be class members. The code 'static int i;' inside amethod() is illegal syntax. This is a compile-time error regardless of initialization.

Multiple choice technology programming languages
  1. short myshort = 99S;

  2. String name = 'Excellent tutorial Mr Green';

  3. char c = 17c;

  4. int z = 015;

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

Option D (int z = 015) is correct - 015 is octal notation for decimal 13. Options A and C are wrong because 'S' and 'c' are not valid suffixes for numeric literals. Option B is wrong because single quotes denote char literals, not String literals.

Multiple choice technology programming languages
  1. 0

  2. 1

  3. 2

  4. 3

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

The output is 1. Tracing: l starts at 0, k = l++ means k gets 0 then l becomes 1. j = ++k means k increments to 1 then j gets 1. i = j++ means i gets 1 then j becomes 2. System.out.println(i) outputs 1.

Multiple choice technology programming languages
  1. Compilation error

  2. Runtime Error

  3. 10

  4. None of these

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

Since 'a' is a compile-time constant (final int), 'x' is also a compile-time constant with a value of 10. The compiler allows assigning 'x' directly to byte 'b' without an explicit cast because its value fits within the range of a byte.