Computer Science, asked by ravi2001choudhpcnt24, 11 months ago

8. What is the output of the following?
char c = 'A';
Short m = 26;
int n = c +m;
System.out.println(n)​

Answers

Answered by arnabhsinha888
38

Answer:

This question will give u a run time error

Explanation:

As all three variables are taken in different data types so type casting needs to be done.

The correct code will be:

char c='A';

int m=26;

ch=(int)c;

n=ch+m;

Here, I have converted the value of 'A' to ASCII value and now ur addition will be done.The answer will be 65+26=91

Answered by sswaraj04
18

Answer:

91

Explanation:

When you are performing operation on different data types then

lower data types are automatically converted to higher data type in java

so here char will be converted to int by Ascii value which is 65 of 'A'

and short wil be converted to int with value unchanged

now

n=c+m

n=65+26 =91

Hope you understand and like it:-)

..

Similar questions