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

  2. A B A B

  3. B B

  4. A B

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

When instantiating B, constructors of A then B run, printing 'A' and 'B'. During deserialization, because superclass A is not serializable, its no-arg constructor is invoked, printing 'A' again, while serializable B's constructor is bypassed. This results in the sequence 'A B A'.

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

Multiple choice technology programming languages
  1. 57 22

  2. 45 38

  3. 45 57

  4. An exception occurs at runtime.

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

The code creates an anonymous subclass of AbstractTest overriding getNum() to return 22. It then instantiates an anonymous subclass of inner class Bar, overriding getNum() to return 57. Evaluating f.getNum() + " " + t.getNum() outputs '57 22'.