Invalid Character Literal Assignment
Which of the following best describes the compile-time error produced by the code segment below?
public class Debug {
public static void main(String[] args) {
char letter = 'AB';
System.out.println(letter);
}
}
A
Incorrect main method parameter type.
B
A char literal must contain exactly one character; ‘AB’ is invalid.
C
Missing semicolon after the declaration of letter.
D
Letter is used before declaration.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | ngvandangthanh | 2 | 2 | 0m 00s | 200 |
| #2 | bommasam000 | 1 | 1 | 0m 13s | 87 |
| #3 | 108185265 | 1 | 1 | 0m 16s | 84 |
| #4 | manveergunesani | 1 | 1 | 0m 17s | 83 |
| #5 | patrickmeijer009 | 1 | 1 | 0m 17s | 83 |
| #6 | lsj08030922 | 1 | 1 | 0m 36s | 64 |
| #7 | parth.taur227 | 1 | 1 | 0m 45s | 55 |
| #8 | y.seong2027 | 1 | 1 | 0m 51s | 49 |
| #9 | demosolasis1 | 1 | 1 | 1m 11s | 29 |
| #10 | theofanusmischa | 1 | 1 | 1m 24s | 16 |
Items per page:
10
1 – 10 of 13
APFIVE