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
  1. Can not predict

  2. 12

  3. Garbage value

  4. Compiler error

  5. Semantics error

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

You can not predict the value of volatile variable because its value can be changed by any microprocessor interrupt.

Multiple choice
    • 5
  1. 4

  2. Lexical error

    • 6
  3. Syntax error

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

Char a = 260. 260 is beyond the range of signed character. Its corresponding cyclic value is -6. a = -6. Operator !, ~ and ++ have equal precedence. First ++ operator performs, so its value is -5. i = -5 + !-5 + ~5 + -5 = -5+0+4-5 = -6.

Multiple choice
  1. 0

  2. 1

  3. 101

  4. 111

  5. 110

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

As instance variables, b1 and b2 are initialized to false. Thus, if tests on lines 7 and 9 are successful, so b1 is set to be true and x is incremented. The next test to succeed is on line 19 (note that the code is not testing to see if b2 is true, it is setting b2 to be true). Since line 19 was successful, subsequent else-if's (line 21) will be skipped. So, this is correct choice.

Multiple choice
  1. Welcome ava

  2. Welcome va

  3. Welcomeava

  4. Compiler error : delete cannot be used with StrinBuffer

  5. Run time error

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

This is the correct answer, delete(int start , int end) deletes the characters from the start index till end-1 index. So, the welcome to java will delete the characters from 8 to 11 characters. So the resulting string remains “ Welcome ava”. Index starts from 0. Hence, this is the correct answer.

Multiple choice
  1. s.length() = 14s.charAt(9) = T

  2. s.length() = 15s.charAt(9) = o

  3. s.length() = 15s.charAt(9) = T

  4. s.length() = 14s.charAt(9) = o

  5. Compiler Error

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

This is wrong. Length() function returns the number of characters in the string. As we can count that the number of characters in the given string are 15. So, length() will return 15 not 14. charAt() function returns the character at the given index in the parameter. Remember that the index count starts at 0. So, charAt(0) is W, counting in this way we reach charAt(9) is o not T.  Hence, this is the correct answer.

Multiple choice
  1. 0

  2. c

  3. Empty string

  4. Compile time error

  5. Run time error

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

This is wrong. Substring method takes two parameters (beginIndex,EndIndex).Substring( int Begin , int End). It returns the string from begin to end – 1. But, if the begin index is equal to the end index then an empty String with length 0 will be returned. So, here substring(4,4) will return an empty string of length 0. Hence, this is the correct answer.

Multiple choice
  1. Default Case Case 1 Case 2 Case 3

  2. Case 1Case 2Case 3

  3. Case 2Case 3

  4. Case 3

  5. Compilation Error

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

There is an error in the program because Math.round() function returns a “long” type of value and we cannot pass a “long” type of value in a switch() case. So the compiler will raise an error that “required:int, Found: long”. So this is the correct choice.

Multiple choice
  1. Default Case 1 Case 2 Case 3

  2. Case 1 Case 2 Case 3

  3. Case 2 Case 3

  4. Case 3

  5. Compiler Error

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

This is the correct choice because there is an error in the Program. Java doesn’t allow us to have Duplicate case labels in a Switch statement. In the given code, Case 2 and Case 3, both evaluate to the same value. So, when we try to compile the code, The compiler will raise an error, “duplicate case label”. So, this is the correct choice.