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
1
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
Social Sciences,
4 months ago
Math,
4 months ago
Math,
4 months ago
Computer Science,
8 months ago
Science,
8 months ago
Science,
1 year ago
Math,
1 year ago