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. checks whether the two strings are equal or not

  2. reverses the string

  3. check whether the string is palindrome or not

  4. compares the StringBuffer and String object

  5. none of the above

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

The above code checks whether the given string is palindrome or not.

Multiple choice
  1. Hi how are you?

  2. Hihow are you ?

  3. Hihowareyou?

  4. Hihow are you?

  5. None of the above

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

Option 2 is correct answer using StringTkenizer class and println() method.

Multiple choice
  1. NullPointerException

  2. ArithmeticException

  3. IOException

  4. ArrayOutOfBoundsException

  5. IllegalAccessException

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

ArithmeticException gets raised whenever an invalid operation has been attempted by the user. For example, in the above expression, the division by zero exception is raised, if the user has provided the zero value for b.

Multiple choice
  1. value of a=110value of b=220

  2. value of a=10value of b=20

  3. value of a=100value of b=200

  4. value of a=100value of b=220

  5. none of the above

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

As super keyword is used to call constructor of parent class, the output of above program will bea=x+super.xb=y+super.ya=100+10=110b=200+20=220.

Multiple choice
  1. Semantic analysis

  2. Syntax analysis

  3. Optimization analysis

  4. Lexical analysis

  5. Code generation

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

This is the first analysis done by compiler. The source code is scaned statement by statement and tokens are framed as shown in question and put into symbol table etc.

Multiple choice
  1. The ELSE clause will be executed.

  2. Control will be passed to the statement following this one.

  3. The value of A will be doubled.

  4. An error will occur and program execution stop.

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

When A=30, the condition (A = 32) evaluates to false, so the code inside the IF block is skipped. Control simply passes to the next statement after END IF. No ELSE clause exists, and no error occurs.

Multiple choice
  1. The statement Stop program will be displayed

  2. The THEN part of the statement will not be executed

  3. An error message will result

  4. The number 8 will be assigned to the variable X

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

When X=22, the condition (X <> 8) is true (22 is not equal to 8), so the THEN clause executes and prints 'Stop program'. Option B is incorrect because the THEN clause does execute. No error occurs or value assignment happens.

Multiple choice
  1. The first executable statement after this statement is executed.

  2.  Answer is correct. is printed.

  3. The program stops executing.

  4. An error message is displayed.

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

When X=7, the expression (X+3)+5 = (7+3)+5 = 15. Since 15 > 10 is true, the THEN clause executes and prints 'Answer is correct.' The program doesn't stop or error; it simply executes the PRINT statement.

Multiple choice
  1. NEW WORLD RECORD!

  2. GOOD RACE

  3. AVERAGE RACE

  4. Nothing is output

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

When Time=120 and Best=121, the condition (Time < Best) is true (120 < 121), so the first branch executes and prints 'NEW WORLD RECORD!' The ELSEIF and ELSE clauses are never reached.

Multiple choice
  1. NEW WORLD RECORD!

  2. GOOD RACE

  3. AVERAGE RACE

  4. Nothing is output

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

When Time=130 and Best=120: First condition (130 < 120) is false. ELSEIF checks (130 < 120+10) = (130 < 130), which is also false (not strictly less than). Thus the ELSE clause executes, printing 'AVERAGE RACE'.

Multiple choice
  1. The message Try out for football team. is displayed.

  2. Nothing happens; program execution simply continues on to the next statement.

  3. An error message is displayed.

  4. The program immediately stops executing.

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

When Height=66, the condition (Height > 66) is false because 66 is not greater than 66 (it's equal). The innermost IF block containing the PRINT statement is never executed. No error occurs; the nested IFs simply complete without action.

Multiple choice
  1. IF (Sex$ = "M") AND (Height > 66) AND (Weight >180) THEN PRINT "Try out for football team." END IF
  2. IF (Sex$ = "M") OR (Height > 66) OR (Weight > 180) THEN PRINT "Try out for football team." END IF
  3. IF (Sex$ = "M") AND (Height > 66) OR (Weight > 180) THEN PRINT "Try out for football team." END IF
  4. IF (Sex$ = "M") AND NOT (Height > 66) AND (Weight > 180) THEN PRINT "Try out for football team." END IF
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The nested IFs require ALL conditions to be true: Sex$ = "M" AND Height > 66 AND Weight > 180. Only option A correctly uses AND to combine all three conditions.

Multiple choice
  1. The variables are compared character by character until one of the values is different.

  2. The variables are ignored.

  3. An error will occur.

  4. The second variable is automatically changed to the data type of the first variable.

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

Programming languages enforce type compatibility when comparing variables. You cannot directly compare a string variable (which stores text) to a numeric variable (which stores numbers) because they represent different kinds of data. This type mismatch will generate an error rather than attempting an invalid comparison.

Multiple choice
  1. Line 1

  2. Line 2

  3. Line 5

  4. Line 6

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

The assignment operator in PL/SQL is := whereas the above code is using the '=' operator which is an equality operator. Therefore, this line will display an error.