Computer Applications
State the values of n and ch.
char c = 'A';
int n = c + 1;
char ch = (char)n;
Values & Data Types Java
ICSE 2012
143 Likes
Answer
Value of n is 66 and ch is B.
int n = c + 1, here due to implicit conversion, 'A' will be converted to its ASCII value 65. 1 is added to it making the value of n 66.
char ch = (char)n, here through explicit conversion 66 is converted to its corresponding character that is 'B' so value of ch becomes B.
Answered By
68 Likes
Related Questions
Which of the following type conversions in Java will result in a loss of precision?
The default value of a boolean variable is:
- False
- 0
- false
- True
Name the keyword which:
- indicates that a method has no return type.
- makes the variable as a class variable
Which of the following is an escape sequence character in Java?
/n
\t
/t
//n