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

Multiple choice technology programming languages
  1. not same

  2. same

  3. unknown symbol ‘~’

  4. none of the above

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

When -1 is assigned to an unsigned int, it wraps around to the maximum value (all bits set to 1). The bitwise NOT of 0 (~0) also produces all bits set to 1. Therefore, both x and y hold the same bit pattern and the comparison 'x == y' evaluates to true, printing 'same'.

Multiple choice technology programming languages
  1. 0001 0002 0003

  2. compile error

  3. 0001 0002 0004

  4. 0001 0002 0006

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

Pointer arithmetic advances by the size of the pointed-to type. char* increments by 1 byte, int* by sizeof(int) (2 bytes on typical 16-bit systems), and long* by sizeof(long) (4 bytes on typical 32-bit systems). Starting from 0, the pointers become 1, 2, and 4 respectively.

Multiple choice technology programming languages
  1. int main()

  2. int main(int argc, char *argv[])

  3. They both work

  4. None of the Above

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

Both int main() and int main(int argc, char *argv[]) are valid main function declarations in C++. The first is for programs without command-line arguments, the second accepts command-line arguments. Both work correctly.