ArrayList Declaration Syntax Error
What is the reason the provided code fails to compile?
import java.util.ArrayList;
public class CapitalizationError {
public static void main(String[] args) {
Arraylist list = new ArrayList();
list.add("Test");
System.out.println(list);
}
}
A
The add method is used with an incompatible argument type.
B
Incorrect capitalization: ‘Arraylist’ should be ‘ArrayList’.
C
The diamond operator is used incorrectly in the ArrayList instantiation.
D
A missing semicolon after list.add(“Test”) statement.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | winstonhou1107 | 1 | 1 | 0m 30s | 70 |
| #3 | geethasailaja | 1 | 1 | 0m 31s | 69 |
| #4 | singhris000 | 1 | 1 | 1m 21s | 19 |
| #5 | bommasam000 | 1 | 2 | 1m 17s | 13 |
| #6 | ravi.palepu | 0 | 1 | 0m 00s | -10 |
| #7 | ganguhas000 | 0 | 1 | 0m 00s | -10 |
| #8 | psak12 | 1 | 1 | 1m 51s | -11 |
| #9 | y.seong2027 | 2 | 2 | 3m 42s | -22 |
| #10 | singh.advik13 | 1 | 1 | 2m 51s | -71 |
Items per page:
10
1 – 10 of 10
APFIVE