Difficulty: Medium
Correct Answer: 1, 3, 6
Explanation:
Introduction / Context:
Java char is a 16-bit unsigned UTF-16 code unit. It can be initialized by a single-quoted character, a Unicode escape within single quotes, or an integral literal within range 0..65535.
Given Data / Assumptions:
Concept / Approach:
Legal forms: char c = 'A'; char c = '\u0041'; char c = 65; Illegal forms include multi-character literals and missing quotes around Unicode escapes.
Step-by-Step Solution:
Verification / Alternative check:
Compile each line independently; only 1, 3, and 6 succeed without additional casts.
Why Other Options Are Wrong:
They include invalid forms (multi-char literal, missing quotes, or illegal escape).
Common Pitfalls:
Forgetting quotes around Unicode escapes; misusing escapes; assuming char can hold strings.
Final Answer:
1, 3, 6
Discussion & Comments