Give the output of the following with explanation:
System.out.println (5+'6'+"7");
System.out.println (5+"7"+'6');
Answers
Answer:
Output:
597
576
I hope this will help you
Answer:
The output of the first line of code, System.out.println(5+'6'+"7");, will be 567.
The output of the second line of code, System.out.println(5+"7"+'6');, will be 576.
Explanation:
The output of the first line of code, System.out.println(5+'6'+"7");, will be 567. This is because the +'6' expression is evaluated as a character, since it is enclosed in single quotes, and has a numeric value of 54 (which is the ASCII value of the character '6'). The numeric value of 5 is then added to 54, resulting in 59. The result is then concatenated with the string "7" to produce the final output "567".
The output of the second line of code, System.out.println(5+"7"+'6');, will be 576. This is because the +"7" expression is evaluated as a string, since it is enclosed in double quotes, and is concatenated with the string representation of the number 5 to produce the string "57". The character '6' is then concatenated to the end of this string to produce the final output "576".
for more questions on Programming
https://brainly.in/question/29838230
#SPJ3