0%
0 / 15 answered
ArrayList Methods Practice Test
•15 QuestionsQuestion
1 / 15
Q1
In this library catalog, what is printed after calling remove and then size?
import java.util.ArrayList;
public class LibraryDemo {
public static void main(String[] args) {
ArrayList<String> books = new ArrayList<String>(); // create catalog
books.add("Dune");
books.add("1984");
books.add("Hamlet");
books.remove(1); // remove "1984"
System.out.println(books.size()); // number of books left
}
}
In this library catalog, what is printed after calling remove and then size?
import java.util.ArrayList;
public class LibraryDemo {
public static void main(String[] args) {
ArrayList<String> books = new ArrayList<String>(); // create catalog
books.add("Dune");
books.add("1984");
books.add("Hamlet");
books.remove(1); // remove "1984"
System.out.println(books.size()); // number of books left
}
}