0

Output of the code?

char a='a'; char b='v'; char c=(char)(a+b); System.out.println(c);

27th Dec 2019, 10:02 AM
Cheliyan
Cheliyan - avatar
2 Answers
+ 1
No output, 'Char' is unknown class, compile error. Run the snippet in Code Playground to find out for yourself. (Edit) Question is edited, apparently the OP meant `char`. Presumably keypad auto-capitalize feature. However, in my opinion minor typo issue like these should and could have been anticipated. And the title also says "Output of the code", without any indication of a need for explanation. When the question asks only for output, I generally recommend to test run the code. If the OP asks for explanation about how the code works, or how it works as it is, then it is a different story.
27th Dec 2019, 10:07 AM
Ipang
+ 1
Ipang probably he meant "char". Cheliyan See the char in Java is unsigned type and the range varies from 0 to 65535 so you must find the Unicode values of both "a" and "v" and add them. Then see what is the corresponding character matching that value on the unicode chart.
27th Dec 2019, 10:19 AM
Avinesh
Avinesh - avatar