Computer Science, asked by venyasehgal29, 1 month ago

char c = 'b';

int d = c +5;

System.out.println(d);​

Answers

Answered by sandesh6463
1

Answer:

In this case the data type incompatibility error will not let this program execute. Change the data type of assignment variable to int like this -

int d=97 ;

int c=(char) d + 10 ;

System.out.println(""+c) ;

now d will be types cast to char. As it’s value is 97 it will be treated as ‘a’. But +10 is being applied in the expression hence ASCII value of ‘a’ (97) will be used. Finally it will become 107.

Another example -

int d=97 ;

int c=(char) d + 10 +’e’ ;

System.out.println(""+c) ;

now output will be 208 as ASCII value of ‘e’ is 101.

Explanation:

plz mark me as brainliest

Similar questions