0

About java

Why i put a char group = 'A'; and the output goes out 68,why? public class Program { public static void main(String[] args) { int value = 23; int res = value / 6; char group = 'A'; System.out.println(group+res); } }

19th Jan 2019, 4:59 AM
Tzion
Tzion - avatar
2 Answers
+ 11
● ASCII code value of character literal 'A' is 65 ● 23/6 is 3 //integer/integer returns integer in java, after removing decimal part. ● implicit typecasting here, from char type to int type(2 bytes to 4 bytes). ● 65+3=68 returned as output.
19th Jan 2019, 5:31 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
System.out.println(group+""+res); Output: A3
19th Jan 2019, 5:43 AM
Denise Roßberg
Denise Roßberg - avatar