Write the output of the code snippet
char c = 'A' ;
int d = 5 ;
int tot = (int)c + d ; System.out.println(tot);
Answers
Answered by
2
Hey Buddy
Here's The Answer
-------------------------------------------------
=> int tot = ( int )c + d ;
In ( int )c we are casting the character into integer and it is know as type casting, if we are casting a character in integer, so the integer will store it's ASCII value.
=> tot = ASCII value of A + d
=> tot = 65 + 5
=> tot = 70
As tot is int we'll get final output in integer form
System.out.println( tot );
=> 70
Hope It Helps.
Similar questions