OutputModerate2 marks
Write the output: char ch = 'F'; int m = ch; m = m + 5; System.out.println(m + " " + ch);
Topic: char arithmetic
Previous-year question practice database
Answer
Exam answer
75 F
Explanation
Assigning a char to an int stores its Unicode value. 'F' is 70 (counting up from 'A' = 65: B 66, C 67, D 68, E 69, F 70). So m becomes 70, then 70 + 5 = 75. The important half of the question is ch. It was never modified — only a copy of its value went into m — so ch is still the character F. The output therefore shows a number and a letter side by side: 75 F. Fix the anchors and questions of this kind become instant: A = 65, a = 97, 0 = 48.
More from Revision Tour I
The full form of JVM is:2026Which of the following occupies 2 bytes of storage?2026In a statement c = c + (x * d + e); which variable is an accumulator?2026Assertion (A): The result of the Java expression 3 + 7/2 is 6.
Reason (R): According to the hierarchy of operators in Java, addition is done first followed by division.2026Evaluate the Java expression:
x = a * b % (++c) + (++a) + (--b);
if a = 7, b = 8, c = 22026System.out.println('Z' + 32); will display:2025