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. Code will give compile time error

  2. Code will give runtime error

  3. Code will print "Equal"

  4. Code will print "Not Equal"

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

In Java, String's toString() method returns the same String object (this). The expression "String".toString() returns the literal "String" itself. Since it's the same literal, the == comparison returns true, so the code prints "Equal". The == operator compares object references for String, not content.

Multiple choice technology web technology
  1. throws exception

  2. automatically generates the ID

  3. compilation error

  4. none of the above

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

The Hibernate mapping configuration with automatically generates incrementing numeric IDs for new entities. When you save a new object, Hibernate reads the next ID value from the database and assigns it. This is a built-in ID generation strategy that requires no manual intervention.

Multiple choice technology programming languages
  1. Run-Time Error

  2. Compile-Time Error

  3. 1 2 3 4

  4. None of above

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

The program declares four integer variables (a=1, b=2, c=3, d=4) and prints them using two printf statements. The first printf outputs a and b, the second outputs c and d with a leading space. The output is 1 2 3 4. Option A and B are incorrect because the code compiles and runs without errors. Option D is incorrect because option C is valid.

Multiple choice technology programming languages
  1. 0 3 -3

  2. Compile-Time Error

  3. 0 3 -1

  4. 0 3 0

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

The expression uses the comma operator which evaluates left operand and returns right operand. --a is prefix decrement so a becomes 0. b++ is postfix increment so b returns 2 then becomes 3. The comma expression (--a, b++) returns 2. Then c = 2 - 3 = -1. Output: a=0, b=3, c=-1. Option A is wrong (c=-3 incorrect). Option D is wrong (c=0 incorrect).

Multiple choice technology programming languages
  1. Compile-Time Error

  2. 10

  3. 6

  4. 2

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

Evaluate comma expressions left to right, returning rightmost value. (a,a) returns a=1. (b,c) returns c=3. (c,d) returns d=4. (d,b) returns b=2. So e = 1 + 3 + 4 - 2 = 6. Option A is wrong - no compile error. Option B would require different arithmetic. Option D is incorrect.

Multiple choice technology programming languages
  1. Compile-Time error

  2. 2.00

  3. %.2

  4. 2.000000

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

The format string "%.2" is incomplete - it lacks a type specifier like 'f' for float. In C, this is undefined behavior, but many implementations will simply print the format string literally when it's invalid, resulting in "%.2" as output. This is a common trick question testing knowledge of proper printf format syntax.

Multiple choice technology programming languages
  1. Compile-Time Error

  2. Run-Time Error

  3. 11

  4. None of above

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

The semicolon ';' is a statement terminator in C, not an operator. Having two semicolons 'int b=6;;' is valid - the second semicolon just creates an empty statement. The program correctly computes c = 5 + 6 = 11 and prints it.

Multiple choice technology programming languages
  1. 2,3

  2. 3,2

  3. 2,2

  4. 3,3

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

The nested loops iterate i from 1-3 and j from 1-2. When i==j (i=1,j=1), continue skips to next j. For i=2, j=2: j%3=2 > 1 is false (2 is not > 1), so no break. printf prints '2'. For i=3, j=1: j%3=1 is not > 1, printf prints '3'. Output: 2,3.

Multiple choice technology programming languages
  1. a=5 b=6

  2. a=6 b=5

  3. a=6 b=0

  4. None of the above

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

The swap macro expands to multiple statements separated by semicolons, not a single compound statement. Without braces, only 'temp=a' executes conditionally. Since 5 > 6 is false, the entire block is skipped. temp is static and initialized to 0 by default. printf outputs 'a=6 b=0' because 'a=b; b=temp;' execute unconditionally after the if block.

Multiple choice technology programming languages
  1. Compile-Time error

  2. 5 -6

  3. 5 65530

  4. none of the above

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

val=5 is unsigned int (typically 16-bit range 0-65535). val-11 = 5-11 = -6, which wraps around to 65530 (65535-6+1). The %u format prints unsigned values, so output is 5 65530. Option A is wrong - no compile error. Option B shows signed behavior which %u won't display.

Multiple choice technology programming languages
  1. Compile-Time error

  2. Run-Time Error

  3. 24

  4. Unpredictable

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

*&z is a pointer dereference of z's address, which just gives z. *&z *= *&x * *&y becomes z *= x * y, or z = 2 * 4 * 3 = 24. The *& operators cancel out - & takes address, * dereferences it. This is a pointer trick question testing understanding of address and dereference operators.