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. The first argument passed into the program

  2. You can't define main like that

  3. The program name

  4. Null value

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

In C and C++, the argv array contains command-line arguments, where argv[0] is conventionally the path or name of the program being executed. Subsequent indices hold the actual arguments passed.

Multiple choice technology programming languages
  1. TRUE

  2. FALSE

  3. Compilation Error

  4. Run-time Error

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

The code uses assignment (=) instead of equality (==). In Java, var = true assigns true to var and returns true, so the condition is true and 'TRUE' is printed. This is a common mistake that compiles and runs but produces unexpected behavior.

Multiple choice technology programming languages
  1. printf("%d\n",p);

  2. printf("%u\n",p);

  3. printf("%lu",p);

  4. printf("%p\n",(void*)p);

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

The %p format specifier is the portable, standard way to print pointer values in C. It requires a void* argument, so (void*) cast ensures proper conversion. Options A, B, and C use incorrect format specifiers - %d expects int, %u expects unsigned int, and %lu expects unsigned long, none of which are guaranteed to correctly represent a pointer on all platforms.

Multiple choice technology mainframe
  1. DISPLAY A,DISPLAY B

  2. DISPLAY A DISPLAY B

  3. DISPLAY A DISPLAY B WITH NO ADVANCING

  4. DISPLAY A WITH NO ADVANCING DISPLAY B

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

To display two variables on the same line using separate DISPLAY statements, use WITH NO ADVANCING after the first DISPLAY statement. This prevents the cursor from moving to the next line after displaying A, so B appears on the same line. Without NO ADVANCING, each DISPLAY statement outputs on a new line. The correct syntax is 'DISPLAY A WITH NO ADVANCING' followed by 'DISPLAY B'.

Multiple choice technology programming languages
  1. Failure

  2. success

  3. Exception will be thrown

  4. Compilation error

  5. Neither

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

The ternary operator has left-associativity. The expression str=(b)?"success": (x=0)?"Failure":"Neither" is parsed as str = ((b)?"success": (x=0))?"Failure":"Neither". Since b is true, the first ternary returns "success". Then it tries to evaluate ("success")?"Failure":"Neither", which attempts to use a String as a boolean condition - this is a compilation error because you cannot use a String as a boolean expression in Java.

Multiple choice technology programming languages
  1. 155

  2. Compilation error

  3. Exception

  4. 20

  5. 5 5

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

The code fails to compile because the variable 'tr' is undefined (it should be 'tp'), and the main method attempts to access a private field 'i' of class Top directly, which is forbidden in Java.