Computer Science, asked by mcjuniadiqbal, 6 months ago

Given: char ch = “D”
Write a Java statement that will replace the current value of the variable ch by a character which is 5

steps ahead of it. (The statement should implement type casting.)​

Answers

Answered by anindyaadhikari13
1

\star\:\:\:\sf\large\underline\blue{Question:-}

Given: char ch = “D”

Write a Java statement that will replace the current value of the variable ch by a character which is 5 steps ahead of it. (The statement should implement type casting.)

\star\:\:\:\sf\large\underline\blue{Answer:-}

The java statement can be written in two ways.

Method 1.

char ch='D';

int a=(int)ch;

a+=5;

ch=(char)a;

Method 2.

char ch='D';

ch+=5;

Similar questions