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

  2. good

  3. morning

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

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

When you run java myprog good morning, the argv array has only 2 elements: argv[0]="good" and argv[1]="morning". Accessing argv[2] causes ArrayIndexOutOfBoundsException because index 2 doesn't exist.

Multiple choice technology programming languages
  1. one

  2. one, default

  3. one, two, default

  4. default

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

When i=1, case 1 matches and prints "one". Since there's no break statement, execution "falls through" to case 2 (prints "two") and then to default (prints "default"). Fall-through is a deliberate (and sometimes useful) feature in Java switch statements.

Multiple choice technology programming languages
  1. runtime exception

  2. 6

  3. 7

  4. comiple error.

  5. 10

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

The variable i is declared inside the for loop header, so its scope is limited to the loop body. When System.out.println(i) executes after the loop, i is out of scope, causing a compilation error. Option A is wrong because there's no runtime - compilation fails. Options B, C, and E are incorrect because the code never runs.

Multiple choice technology programming languages
  1. Runtime exception

  2. 6

  3. 7

  4. Compile Error

  5. 11

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

The variable i is declared inside the for loop header (int i=0), limiting its scope to the loop body. The System.out.println(i) statement after the loop tries to access i outside its scope, causing a compilation error. Options A, B, C, and E are incorrect because the code never compiles or runs.

Multiple choice technology programming languages
  1. True

  2. False

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

Java 1.5 introduced autoboxing, which automatically converts primitive int to Integer when needed. The statement mylist.add(5) works because the int 5 is autoboxed to Integer. The code compiles and runs without error, so the statement that it gives compilation error is false.

Multiple choice technology programming languages
  1. a(100, 200), b(100, 200)

  2. a(100, 200), b(700, 800)

  3. a(700, 800), b(100, 200)

  4. a(700, 800), b(700, 800)

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

In Java, objects are passed by reference. Method a modifies the actual object's fields, changing x to 100 and y to 200. Method b reassigns the local reference variable to a new Point object, but this doesn't affect the original object. So after method a: (100, 200), after method b: (700, 800) unchanged.

Multiple choice technology programming languages
  1. 33, 33

  2. 123, 33

  3. 33, 123

  4. 123, 123

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

In the first statement, 1+2=3 is evaluated first (arithmetic before string concatenation), then concatenated with "3" to produce "33". In the second statement, "1"+2 produces "12" (string concatenation), then "12"+3 produces "123". String concatenation starts when a string is encountered.

Multiple choice technology programming languages
  1. Compilation error.

  2. Runtime error

  3. Compiles Fine

  4. Depends on the code where you use

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

This code has a type mismatch - List expects Object elements, but ArrayList can only contain Strings. In Java generics, you cannot assign a more specific generic type (ArrayList) to a more general reference (List) because it would allow type violations at compile time.

Multiple choice technology programming languages
  1. Compilation Error

  2. Some Unknown Random Number

  3. 5

  4. I Dont Know

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

The printf statement uses %u format specifier with ThatsMyFunction without parentheses, so it prints the function's memory address (a random-looking number) instead of calling it. To print the return value 5, you need ThatsMyFunction(). The %u format expects unsigned int, and a function pointer address fits this.