int a=Integer.parseInt("97");
int n=a+2;
System.out.println((char)n);
Answers
Answered by
8
int a = Integer.parseInt("97");
int n = a + 2;
System.out.println((char)n);
c
int a = Integer.parseInt("97");
> Here, the parseInt() methods converts the given string to integer.
Therefore:
> a = 97
——————————————————————————
int n = a + 2;
> Here, 2 is added to variable 'a' and the result is stored in variable n.
> n = 99
——————————————————————————
System.out.println((char)n);
> The character whose ASCII value is 99 is displayed (using type casting). The required character is - small letter 'c'.
So, the output for the given code is - c.
Similar questions