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
  1. Starting to waitGoes an infinite wait and deadlock

  2. Starting to waitException found

  3. Starting to waitDone waiting, returning back

  4. Starting to waitInterruptedException Found

  5. None of these

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

Correct choice The wait() method calls without lock so it causes IllegalMonitorStateException, which catch block finds Exception.

Multiple choice
  1. Cannot call super class constructor Call to the super must be first in the constructor.

  2. 000455

  3. 000005

  4. 000450

  5. 000000

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

super(*) keyword should be the first line constructor, in which it is defined.

Multiple choice
  1. 01045010

  2. 0104505

  3. 0104545

  4. error:non static object cannot be referenced from static context

  5. 01045

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

It is the correct choice as it has to create call through object like ob1.test(), without which it is creating an error.

Multiple choice
  1. point

  2. Point

  3. [0, 0]

  4. [10, 0]

  5. [10, 20]

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

The assignment x = x; inside the construct reassigns the passed parameter. It does not assign the memberx in sample5. The correct way to perform the assignment is this.x = x;. Field y is not assigned, so its value remains 0.

Multiple choice
  1. 0

  2. Error in the importing package

  3. Compile time error

  4. 1

  5. Both 2 and 3

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

Correct choice System class is present in java.lang package. As it is a final class, it calls println() through static printstream object out, so we initially import static java.lang.System.out, which initially declares static object out.

Multiple choice
  1. When executed, this program printsk == j is falsek.equals(j) is false

  2. When executed, this program printsk == j is truek.equals(j) is false

  3. When executed, this program printsk == j is falsek.equals(j) is true

  4. When executed, this program printsk == j is truek.equals(j) is true

  5. When compiled, the program will result in a compiler error in the line marked with the comment INCR.

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

Equals () function return true when they have same memory location assigned to it.

Multiple choice
  1. s1 and s2 equal s1 and s3 equal

  2. s1 and s2 equal s1 and s3 not equal

  3. s1 and s2 not equal s1 and s3 not equal

  4. s1 and s2 not equal s1 and s3 equal

  5. None of the above

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

JVM sets a constant pool in which it stores all the string constants used in the type. If two references are declared with a constant, then both refer to the same constant object. The == operator checks the similarity of the objects itself (and not the values in it). Here, the first comparison is between two distinct objects, so we get s1and s2 not equal. On the other hand, since references of s1 and s3 refer to the same object, we get s1 and s3 equal.