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

  2. Compile Time Error

  3. 20

  4. 020

  5. 200

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

since i is protected and it will be visible at all its sub classes

Multiple choice
  1. Displays a rectangle of 200X200 pixels starting with top left corner at 40X40 pixels

  2. Displays a rectangle of 40X400 pixels starting with top left corner at 200X200 pixels

  3. Displays a circle of 200X200 pixels starting with top left corner at 40X40 pixels

  4. Displays a circle of 40X40 pixels starting with top left corner at 200X200 pixels

  5. None of the above

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

This statement will draw the rectangle of 200X200 at left corner at 40X40 of the screen.

Multiple choice
  1. Frame is not defined properly.

  2. Statement import java.awt.*; is missing.

  3. Statement import java.net.*; is missing.

  4. Statement import java.io.*; is missing.

  5. Set size is not defined properly.

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

This statement is must, because awt application is used to create the frame. This application is missing.

Multiple choice
  1. 34

  2. 35

  3. 24

  4. Run time error

  5. Compilation error

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

The two elements 3 and 4 (starting from position with index 2) are copied into position index 1 and 2 in the same array. After the array copy command, the array looks like: {1, 3, 4, 4, 5}.Then, element with index 1 is printed: 3. Then, element with index 4 is printed: 5.

Multiple choice
  1. They Match They Really Match

  2. They really Match

  3. They Match

  4. Blank Output Screen

  5. Compilation fails

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

Strings cannot be compared with the usual <, <=, >, or >= operators, and the == and != operators don't compare the characters in the strings.  

Multiple choice
  1. They matchThey really match

  2. They really match

  3. They match

  4. Nothing will be printed

  5. Compilation fails

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

The strings are not the same objects. So, the == comparison fails. As the values of the strings are the same, equals is true. The equals method compares values for equality. == compares references, not values. The use of == with object references is generally limited to the following: Comparing to see if a reference is null. 

Multiple choice
  1. Blank output screen

  2. StringIndexOutofBound exception

  3. ArrayIndexOutofBound exception

  4. ‘\0’ will be printed

  5. Compilation fails

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

There are only 11 characters in the string hello world. The code theString.charAt(11) retrieves the 12th character, which does not exist. A StringIndexOutOfBoundsException is thrown. Exception in thread main is java.lang. StringIndexOutOfBoundsException. So, this answer is correct.

Multiple choice
  1. Zero times

  2. Once

  3. Twice

  4. Thrice

  5. Compilation fails

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

The above program produces output: aa, 0aa, 1aa, 2bb, 0bb, 1bb, 2cc, 0cc, 1cc, 2. So, 2 will be printed thrice. Hence, this answer is false.

Multiple choice
  1. Found 3 at 2

  2. Found 3 at 3

  3. Found 3 at 4

  4. Compilation fails

  5. Run time error

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

The following line does not compile: System.out.print (found + key + at + pos). 

Multiple choice
  1. Zero

  2. Once

  3. Twice

  4. Thrice

  5. Compilation error

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

This is the correct choice. The for statement, for (String ss: table) is executed one time for each of the three elements in table.