多选题 What best describes the result of the following code segment? The ArrayList sampleArrayList has already been declared and initialized.
int i = 63;
sampleArrayList.add(i);
  • A. The int is successfully placed into the ArrayList.
  • B. The int is converted to an Integer via autoboxing and then placed into the ArrayList.
  • C. null is placed into the ArrayList.
  • D. A compile time error will be generated.
  • E. A runtime exception will be thrown.
【正确答案】 B
【答案解析】基本数据类型不能存储在ArrayList中。但是,如果它们被放置到其基本数据类型的封装类中,则可以存储。如果一个基本数据类型被放入ArrayList中,则Java将通过其自动装箱功能自动转换。A、C、D和E不正确。A不正确,因为int不能直接放入ArrayList中。C不正确,因为null不能放入ArrayList中。D和E不正确,因为它们是正确的代码。