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. 10 & 12

  2. 10 & 10

  3. Compile Time Error

  4. None

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

The statement int x=y=10; attempts to use variable y before declaration. In Java, all variables must be declared before use, making this a compilation error. The chained assignment syntax requires all variables to be pre-declared or declared together.

Multiple choice technology testing
  1. 2

  2. 3

  3. 1

  4. Syntax Error

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

The batch script contains a syntax error on the line '%var%+=1'. This is not valid batch syntax - arithmetic operations require 'set /a var=%var%+1'. Additionally, 'set var = 1' creates a variable with a space in the name, and 'echo var' prints the literal string 'var' rather than the variable's value.

Multiple choice technology testing
  1. Prints numbers from 6 to 9 into c:\test.txt

  2. Prints numbers from 5 to 10 into c:\test.txt

  3. Prints only 10 to c:\test.txt

  4. Infinite loop

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

The loop initializes number=5, then increments it before each check. When number becomes 6 through 9, it echoes these values to the file. When number reaches 10, the condition is true and execution jumps to :label, exiting the loop. Thus only numbers 6, 7, 8, and 9 are written to c:\test.txt.

Multiple choice technology programming languages
  1. I gave

  2. Questions and

  3. Answers

  4. in this question.

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology operating systems
  1. Hello World!Hello World!

  2. Hello World!

  3. World!Hello

  4. error

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

fork() creates a child process that duplicates the parent. Both processes continue execution from after the fork() call, so each executes the printf statement. The output appears twice: "Hello World!Hello World!". The order may vary but both processes print.

Multiple choice technology web technology
  1. 1.5

  2. 1

  3. RuntimeException

  4. CompileTime Error

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

In Java, dividing two integers yields an integer (int). Assigning it to a byte without casting causes a compile-time error. Additionally, using & as a unary address operator is invalid syntax in Java and fails compilation.

Multiple choice technology programming languages
  1. Runtime Exception

  2. 1.5

  3. 1

  4. CompileTimeError

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

Integer division in Java truncates toward zero, so 3/2 equals 1 (not 1.5). The result is assigned to byte c. This compiles without error because the compiler knows 1 is within byte range (-128 to 127). The output is "c=1".

Multiple choice technology programming languages
  1. Ram

  2. prasad

  3. RamPrasad

  4. PrasadRam

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

The concat() method returns a new String object without modifying the original. Since s1.concat(s2) is not assigned to any variable, s1 remains "prasad". This demonstrates String immutability - operations that appear to modify Strings actually create new ones.

Multiple choice technology programming languages
  1. prasad

  2. true

  3. false

  4. compileTime Error

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

The expression "c="+s1==s2 is evaluated as ("c="+s1)s2 due to operator precedence - string concatenation (+) happens before the equality check (). The concatenation creates a new String object "c=sanjay", which is then compared by reference to s2. Since s2 is a different String object (even though it contains "sanjay"), the == operator returns false. To compare string content, use .equals() instead.