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. The code compiles and produces output: int version.

  2. Line 9 will not compile as there is no version of myMethod which takes a char as argument.

  3. An exception at line 9.

  4. Line 4 will not compile as void methods can't be overridden.

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

Java performs widening conversion from char to int when no exact method match exists. The primitive char type is promoted to int to match myMethod(int), not String, because String is an object reference type.

Multiple choice technology programming languages
  1. Compile successfully, nothing is printed

  2. Runtime error

  3. Compilation error

  4. Inside throwMethod. followed by caught: java.lang.IllegalAccessExcption: demo

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

IllegalAccessException is a checked exception in Java. Any method throwing a checked exception must either declare it with a throws clause or catch it - throwMethod does neither, causing compilation error.

Multiple choice technology programming languages
  1. 0122

  2. 0123

  3. Compilation error

  4. None of these

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

The loop variable i is scoped to the for-loop block only. Attempting to access i outside the loop violates Java's scoping rules - local variables declared in loop initialization are not visible after the loop terminates.

Multiple choice technology programming languages
  1. 0122

  2. 0123

  3. Compilation error

  4. None of these

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

The variable i is declared within the initialization of the for loop, meaning its scope is restricted to the loop body. Referencing i outside the loop in the subsequent print statement causes a compilation error, making other choices incorrect.

Multiple choice technology programming languages
  1. Hello World

  2. out.print("Hello World");

  3. No output is generated by this line

  4. "Hello World"

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

The syntax <%-- ... --%> represents a JSP comment, which is processed entirely server-side and ignored during compilation, resulting in no output. The distractors are incorrect because they assume the code executes or outputs the string literal, which only occurs with scriptlets or expressions.

Multiple choice technology testing
  1. A. Memory Analysis, Performance Analysis, Code Coverage Analysis

  2. B. Memory Analysis, Stress Test Analysis, Code Analysis

  3. C. Performance Analysis, Static Analysis, Performance Analysis

  4. D. None

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

JProbe is a suite consisting of tools for memory debugging, performance profiling, and code coverage analysis. The distractors are incorrect because JProbe does not perform static analysis or stress testing, which are typically handled by other tools or IDE features.

Multiple choice technology testing
  1. Memory Analysis

  2. Performance Analysis

  3. Coverage Analysis

  4. Static Analysis

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

When an application continuously crashes, it often indicates memory issues such as memory leaks, null pointer exceptions, or out-of-memory errors. Memory Analysis helps identify these problems by tracking object allocations, garbage collection patterns, and memory usage patterns that lead to crashes. Performance Analysis would be used for slowness or hanging, Coverage Analysis for test completeness, and Static Analysis for code quality without running the application.

Multiple choice technology programming languages
  1. 2

  2. 1 2

  3. 2 3

  4. 1 2 3

  5. Compilation fails.

  6. Exception is thrown at runtime

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

The first condition (x==4) is false since x=5, so '1' is not printed. '2' always prints. The second if assigns b2=true and checks b1=true, so both conditions are true and '3' prints. Output is '2 3'. Note the assignment (b2=true) inside the condition.

Multiple choice technology programming languages
  1. args.count

  2. args.length

  3. args.count()

  4. args.length()

  5. args.getLength()

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

In Java, the args parameter is an array. Arrays have a length property (not a method), so args.length returns the number of command-line arguments. The other options use incorrect syntax like count(), getLength(), or treating length as a method.

Multiple choice technology programming languages
  1. Compilation fails.

  2. An exception is thrown at runtime

  3. The variable first is set to null.

  4. The variable first is set to elements[0].

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

The ternary operator checks if elements.length > 0 (true since array has 3 elements), so it returns elements[0] which is 'for'. The colon separates the true and false branches - elements[0] is assigned to first. The array initialization syntax is valid.

Multiple choice technology programming languages
  1. String value.............null

  2. Exception

  3. Compiler Error

  4. Integer value.............0

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

The code creates ambiguity because both overloaded displayVal methods can accept zero arguments. The String... varargs and int... varargs methods are both valid candidates for the call displayVal() with no parameters. Java cannot determine which method to invoke, resulting in a compile-time error.

Multiple choice technology programming languages
  1. No observations

  2. x y {A 1} {A 2} {B 2}

  3. x y {A 1} {A 2}

  4. x y {A 1} {A 2} {B .}

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

The SAS DATA step uses line-hold specifier @ to hold the current record. For 'A' records, it reads the next line/value y. For the 'B' record, it doesn't execute the inner input for y, causing y to remain missing (.) for that observation. The output contains observations for A (1), A (2), and B (.).