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. AB

  2. ABC

  3. 6566

  4. Compiler error

  5. 01

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

This is the correct option as the variable alpha is initialized with the value 65, which is an ASCII equivalent of 'A'. Since, 'for' loop lasts for the values 0 and 1, therefore the values 65 and 66 are initialized to the char array 'ch' that is nothing but ASCII value of 'A' and 'B'.

Multiple choice
  1. <span style="font-size:11.0pt;line-height:115%;font-family:"Calibri","sans-serif";mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times" new="">The program prints 'I am the best' three times.

  2. <span style="font-size:11.0pt;line-height:115%;font-family:Calibri,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Times" new="">The program prints 'I am the best' infinite times.

  3. <span style="font-size:11.0pt;line-height:115%;font-family:Calibri,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Times" new="">The program prints 'I am the best' only once.

  4. <span style="font-size:11.0pt;line-height:115%;font-family:Calibri,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Times" new="">The compiler reports an error since main() cannot call itself.

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

This option is correct because when the compiler prints 'I am the best' for the very first time, it subsequently reads exit() and the program execution comes to an end. Hence, the statement will be printed only once.

Multiple choice
  1. ome

    • 1
  2. com

  3. run time error

  4. compile time error

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

This is the correct answer. Substring method takes two parameters (beginIndex,EndIndex).Substring( int Begin , int End). It return the string from begin to end – 1.But if the begin index is greater than the endindex, then a "IndexOutOfBoubd" exception will occur. So here substring(4,3) will give runtime error.So this is the correct answer.

Multiple choice
  1. true

  2. false

    • 1
  3. compile time error

  4. run time error

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

This is the correct answer. The compiler will throw an error that method match() was not declared.Because String class do not contains any method named match().The correct method is matches(). So the above statement should be s.matches(s1).So this is the correct answer.

Multiple choice
  1. a

  2. v

  3. compiler error : cannot pass a function as parameter

  4. compiler error : parameters not sufficient

  5. runtime error

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

This is the correct answer. S.length() wil return 15 because there are 15 characters in the String.So the code looks like this :-s.charAt(15);the index count starts at 0. In this way the last character a is at index number 14. So if we try to access a character in a string which is out of bound then a runtime exception “StringOutOfBound” will be thrown.So we can pass only till s.charAt(s.length()-1).So this is correct answer.

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) delete 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.So 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 the correct answer. Length() function return 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.charAt() function return 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.So this is the correct answer.

Multiple choice
  1. o

  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 the correct answer. Substring method takes two parameters (beginIndex,EndIndex).Substring( int Begin , int End). It return the string from begin to end – 1.But if the begin index is equal to the endindex then an empty String with length 0 will be returned. So here substring(4,4) will return an empty string of length 0.So this is the correct answer.