Q: System.out.println('Z'+32); will display:
D
Answer:
D
Explanation:
The correct answer is:
(d) 154
Explanation:
In the expression:
System.out.println('Z' + 32);
-
The character 'Z' has an ASCII value of 90.
-
The integer 32 is added to it:
90 + 32 = 122.
-
Since both 'Z' (char) and 32 (int) are involved in an arithmetic operation, 'Z' is promoted to an integer before addition.
-
The result is 122, which is the ASCII value of 'z', but since no type casting is done, it prints the integer 122 instead of the character 'z'.
So, the correct answer should be (c) 122, not (d) 154. Please verify your answer choices.
Related Topic:
Share Above MCQ