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

  2. 000

  3. 333

  4. 433

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

j dereferences pointer j (which points to I) giving 3. **k dereferences k twice: k points to j, j points to I, so **k = 3. However, *(*k) is problematic - *k gives j's value (address of I), then dereferencing that address as if it were a pointer ((*k)) is incorrect. The actual output would be unpredictable, but the question expects 333 assuming *(*k) is treated as **k.

Multiple choice technology programming languages
  1. 1234

  2. 13

  3. 1

  4. Compilation Error

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

When main executes, it prints '1'. Inside the try block, the return statement is encountered. However, the finally block is guaranteed to execute before the method returns. The finally block prints '3' and the method exits. The code after the try-catch-finally block ('4') is never reached.

Multiple choice technology programming languages
  1. 12 false

  2. Compiler error on line 6

  3. Compiler error on line 12

  4. Compiler error on line 11

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

Line 11 fails because millis is private (line 2) and cannot be accessed from subclass AppyFizz. Private members are visible only within their own class. carbonated (line 3) has default access and is visible, but millis causes compilation failure. Option D correctly identifies the error location.

Multiple choice technology architecture
  1. i L

  2. i N

  3. S L

  4. S N

  5. Compilation fails.

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

For go(a1): short primitive widens to int, calling go(int) and printing 'i'. For go(new Integer(7)): Integer is an Object, not a primitive. It doesn't match go(Long) (Integer != Long), doesn't match go(Short) (Integer != Short), so it matches go(Number) because Integer IS-A Number. Output is 'i N'. This tests method overloading resolution with autoboxing and widening reference conversions.

Multiple choice technology architecture
  1. The program will output 'hello:1:2.0:false'

  2. The program will throw Input Mismatch exception at the run-time

  3. The program will output nothing.

  4. The program will ouput ':1:2.0:false'

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

The Scanner with space delimiter correctly parses: scanner.next() returns 'hello', scanner.nextInt() parses '1', scanner.nextFloat() parses '2.00' as 2.0, scanner.nextBoolean() parses 'false'. The output concatenates these: 'hello:1:2.0:false'. No InputMismatchException occurs because the tokens match the expected types.

Multiple choice technology architecture
  1. Compile time Error at line 1

  2. Compile time Error at line 3

  3. Compile time Error at line 4

  4. Compile time Error at line 5

  5. Run Time Error

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

Line 5 causes a compile-time error: you cannot cast Gen to Gen because generic types are invariant. Even though type erasure means both become Gen at runtime, the compiler enforces type safety. The cast (Gen)new Gen(1) is trying to convert one generic type to another incompatible generic type, which the compiler rejects. Line 4's raw Gen cast is allowed (unchecked warning), line 3's unparameterized Gen(1) matches the raw array, and line 1's raw array creation is legal.

Multiple choice technology architecture
  1. default

  2. default, zero

  3. error default clause not defined

  4. no output displayed

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

When i=9, no case matches, so default executes. The default clause lacks a break statement, causing fall-through to case 0, which prints 'zero'. Thus both 'default' and 'zero' are printed.

Multiple choice technology architecture
  1. myprog

  2. good

  3. morning

  4. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"

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

Command-line arguments populate argv array starting from index 0. With only two arguments ('good', 'morning'), argv[2] is out of bounds, throwing ArrayIndexOutOfBoundsException: 2.

Multiple choice technology architecture
  1. Error: anar is referenced before it is initialized

  2. null

  3. 0

  4. 5

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

In Java, primitive arrays are initialized with default values upon instantiation. An int array of size 5 will have all its elements automatically initialized to 0. Accessing index 0 returns 0, and the program compiles and runs successfully.

Multiple choice technology architecture
  1. No such file found

  2. No such file found ,-1

  3. No such file found, Doing finally, -1

  4. 0

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

FileNotFoundException is caught, printing 'No such file found' and returning -1. The finally block always executes, printing 'Doing finally' before the return completes. Output order is: error message, then finally block, then return.