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. 3,7

  2. 3,5,7

  3. index Outofbound exception

  4. Compilation fails

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

The code fails to compile because Java generics cannot use primitive types. 'List' and 'ArrayList()' are invalid - you must use wrapper types like 'List' and 'ArrayList'. The compiler will reject this code at the declaration line, so no execution occurs.

Multiple choice technology programming languages
  1. 3,7

  2. 3,5,7

  3. index Outofbound exception

  4. Compilation fails

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

Java generics do not support primitive types like int; they require reference types like Integer. Therefore, declaring List causes a compilation failure. Additionally, iterating over myList using a String loop variable would also fail compilation.

Multiple choice technology programming languages
  1. A

  2. ABC

  3. comilation fails

  4. AB

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

Compilation fails for two reasons: (1) Switch statements on Boolean wrapper types are not supported in Java - only int-compatible types, enums, and String (Java 7+) are allowed. (2) The case syntax case(true) with parentheses is incorrect even for valid switch types; cases must use constant values without parentheses.

Multiple choice technology programming languages
  1. The compiler interprets the bytecode in the Java class file

  2. The Java Virtual Machine (JVM) interprets the bytecode in the Java class file

  3. The JVM interprets the native machine code

  4. The JVM translates compiled bytecode to machine code

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

The Java platform uses the JVM to execute bytecode. The JVM can either interpret the bytecode directly or use JIT compilation to translate it to native machine code. The compiler's job ends after creating the class file - it doesn't execute code.

Multiple choice technology programming languages
  1. 15,15

  2. 12,12

  3. 12,15

  4. 15,12

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

StringBuffer is initialized with capacity 15, but capacity is the allocated space, not the actual content length. The string "Hello World!" contains 12 characters (including space and exclamation). The length() method returns 12 (actual characters), while capacity() returns 15 (allocated space). Therefore, the output is "12,15".

Multiple choice technology programming languages
  1. True

  2. False

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

The expression compares a string literal and a new string object using reference equality (==) which returns false, and content equality (equals) which returns true. The XOR operator (^) evaluates false ^ true as true because the operands differ.

Multiple choice technology programming languages
  1. Hallo World!

  2. Hello World!

  3. Compile time error

  4. NullPointerException

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

Strings in Java are immutable - the replace() method returns a new String object but does not modify the original. The line myString1.replace('e', 'o') creates "Hallo World!" but the result is discarded. Since myString1 is not reassigned, it still contains "Hello World!", which is printed.

Multiple choice technology programming languages
  1. Java Programming

  2. Compile time error

  3. Throws exception

  4. Java Program

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

The setLength() method truncates the StringBuffer content to the specified length. "Java Programming" has 16 characters, but setLength(12) keeps only the first 12 characters: "Java Program". The remaining 4 characters "ming" are discarded.

Multiple choice technology programming languages
  1. 80

  2. 3.2

  3. 3

  4. 1

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

In this REXX code, the operator % performs integer division (not floating-point division). X=16 and Y=5, so Z = 16 % 5 = 3 (the integer quotient, ignoring the remainder). Option A (80) would be multiplication (*), and option B (3.2) would be regular division (/). REXX uses % specifically for integer division, which truncates toward zero.