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 web technology
  1. true

  2. false

  3. Compile Error

  4. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Multiple choice technology programming languages
  1. 0.9

  2. 0.90

  3. It varies

  4. None of the above

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

Due to binary floating-point representation, 2.00 - 1.10 does not equal 0.9 exactly. In binary, 0.1 cannot be represented precisely (it's a repeating fraction in binary). The actual result is 0.8999999999999999. Since none of the options A (0.9), B (0.90), or C (It varies - suggests randomness) are correct, the answer is D (None of the above).

Multiple choice technology programming languages
  1. 100

  2. 101

  3. 102

  4. None of the above

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

This loop appears to count from (Integer.MAX_VALUE - 100) to Integer.MAX_VALUE, which should be 101 iterations. However, when i equals Integer.MAX_VALUE and we execute i++, it overflows to Integer.MIN_VALUE (most negative int). The condition i <= end is then always true (since MIN_VALUE <= MAX_VALUE), creating an infinite loop. The count will increase indefinitely.

Multiple choice technology programming languages
  1. HaHa

  2. Ha

  3. Compile error

  4. None of the above

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

The first print uses string concatenation: "H" + "a" = "Ha". The second print involves character arithmetic: 'H' + 'a' promotes chars to int, resulting in 72 + 97 = 169. The output is "Ha169" (or "Ha" followed by 169). Since this exact output isn't listed, the answer is "None of the above".

Multiple choice technology programming languages
  1. Object

  2. double array

  3. Compile Error

  4. None of the above

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

When null is passed to overloaded constructors, Java selects the most specific type. Since double[] is more specific than Object, the compiler selects the double array constructor. This follows Java's overload resolution rules where reference type arrays are more specific than Object.

Multiple choice technology programming languages
  1. It creates an array of classes

  2. Gives compile time error

  3. It creates an array of objects

  4. It does nothing

Reveal answer Fill a bubble to check yourself
C Correct answer
Multiple choice technology programming languages
  1. The class compiles and runs, but does not print anything.

  2. The number 1 gets printed with AssertionError

  3. The number 2 gets printed with AssertionError

  4. The number 3 gets printed with AssertionError

  5. The program generates a compilation error.

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

In the first iteration, i = 1. In the inner loop, when j decreases to 1, the assertion condition i != j becomes 1 != 1 (false). Since assertions are enabled, this triggers an AssertionError with the value of i (which is 1). Other options are wrong because the assertion fails before i can reach 2.

Multiple choice technology programming languages
  1. compiletime error at lines 1,2,3,4

  2. compiletime error at line 3

  3. compiletime error at line 1

  4. compiletime error at lines 3,4

  5. None of the above

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

In standard Java, interface methods are implicitly public and abstract. Explicitly declaring them as protected (line 3) or private (line 4) causes compile-time errors. Distractors are incorrect because lines 1 and 2 are valid method declarations that compile without issues.

Multiple choice technology programming languages
  1. prints object created

  2. Compile time error

  3. Runtime Excepion

  4. None of the above

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

Java allows static nested classes inside interfaces. The syntax C1.I.C2 is valid - C2 is a static class inside interface I, which is inside class C1. The code compiles successfully and creates the object, printing 'object created'. No compile-time or runtime errors occur.

Multiple choice technology programming languages
  1. It will fail to compile.

  2. Runtime error

  3. Compiles and runs with no output.

  4. Compiles and runs printing "Hello"

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

The code compiles and runs successfully because the main() method is inherited from the Base class. Even though Test extends Base, static methods are not inherited in the traditional sense - they belong to the class where they're defined. However, when you run 'java Test', it executes Base.main() which prints "Hello".

Multiple choice technology programming languages
  1. Compiler error.

  2. Compiles and runs printing out 2

  3. Compiles and runs printing out 1

  4. An ArrayIndexOutOfBounds Exception at runtime

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

Java passes references by value. The array reference a is copied to parameter i in the increment method, allowing modification of the original array's elements. The method correctly increments the last element from 1 to 2. The other options are wrong because the code compiles successfully and does not throw runtime exceptions.

Multiple choice technology programming languages
  1. Compiler error.

  2. Will throw a NoSuchMethod error at runtime.

  3. It will compile and run printing out "10"

  4. It will run with no output.

  5. It will run and print "10" and then crash with an error.

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

The code compiles and runs successfully. Static blocks are executed when the class is loaded, and static methods can be called from static blocks. The print(10) method is static, so it's accessible from the static block. The program prints "10" and then exits immediately due to System.exit(0).