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. a=24, b=24

  2. a=12, b=24

  3. We cannot perform addition in pointers(*pt+5)

  4. None of these

  5. Error in the program

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

First the value of c=3 is assigned to pt by the statement pt=&c. So in a1=3(c+5), it becomes a1=3*(3+5). So result is a1=24. After that we know that pt is equal to the value of c,  which is 3. So, a2=3(pt+5) becomes a2=3(3+5). The result is again 24. So, both ai and a2 are 24. Therefore, this is the correct option.

Multiple choice
  1. GoodBoy

  2. Good

  3. Boy

  4. None of these

  5. Error in the program

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

The program will switch the statements with the value x=’G’. If (x==’B’), then if part will be executed. But x is equal to ‘G’. So, else part will be executed. Now the question arises that why default is executed. As we can see that else part contains the default part. Therefore, default is also executed with case ‘G’. So, the result is GoodBoy.

Multiple choice
  1. a=5, b=15

  2. a=15, b=15

  3. a=5, b=5

  4. a=15, b=5

  5. Error in the program

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

In this program first we assign the value of a to b by the statement (b=&a), which means b contains value of a. Now after that **c contains the value of b (c=&b), which means value of b is in **c. Now we assign **c=15, which means **c=15 and b is also become 15 as (c=&b). Now as (*b=*c), it makes b=15. Now as we know (*b=&a), so value of a also becomes 15. In this way both a and b will be printed as 15.

Multiple choice
  1. Invalid number

  2. Result is 425

  3. Result is 625

  4. Result is 525

  5. Error in the program

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

The answer would be 425. The program will firstly find 25%10 which comes out to be 5. So if(d==5) becomes true, then 25/10=2 will be stored in s. And s*s++ will give the result 6 and d*d gives the result 25. So, 625 will get printed.

Multiple choice
  1. Executable code

  2. Bytecode

  3. Bitcode

  4. Assembly language code

  5. None of these

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

The output of compiler is bytecode, which is a platform independent file.

Multiple choice
  1. WWEWELWELCWELCOWELCOMWELCOM

  2. WELCOMEWELCOMWELCOWELCWELWEW

  3. W WE WEL WELC WELCO WELCOM WELCOME

  4. WELCOME

  5. None of the above

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

A is an array having value “WELCOME “. So at 0th position W is present.i=0a.substring(0,0) =>Wi=1a.substring(0,1) =>WEi=2a.substring(0,2) =>WELTherefore option ‘1’ is correct answer.

Multiple choice
  1. Separates digits and reverses the number

  2. Reverses the number

  3. Addition of digits of the given input number

  4. All of the above

  5. None of the above

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

The above code fragment separates the digits and does addition of digits of the given number 4325. The output of the given program code is 14.

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.