0%
0 / 15 answered
ArrayList Methods Practice Test
•15 QuestionsQuestion
1 / 15
Q1
Identify the error in this student database code and choose the best correction.
import java.util.ArrayList;
public class StudentDemo {
public static void main(String[] args) {
ArrayList<String> students = new ArrayList<String>();
students.add("Mia");
students.add("Noah");
students.remove("0"); // intended to remove first student
System.out.println(students.size());
}
}
Identify the error in this student database code and choose the best correction.
import java.util.ArrayList;
public class StudentDemo {
public static void main(String[] args) {
ArrayList<String> students = new ArrayList<String>();
students.add("Mia");
students.add("Noah");
students.remove("0"); // intended to remove first student
System.out.println(students.size());
}
}