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
4
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.)
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