Computer Science, asked by dhruvmberlie, 12 days ago

int a=Integer.parseInt("97");
int n=a+2;
System.out.println((char)n);

Answers

Answered by anindyaadhikari13
8

\textsf{\large{\underline{Given C{o}de}:}}

int a = Integer.parseInt("97");

int n = a + 2;

System.out.println((char)n);

\textsf{\large{\underline{O{u}tput}:}}

c

\textsf{\large{\underline{Explanation}:}}

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 co‎de is - c.

Similar questions