ArrayList Study Pack
What prints after this runs: ArrayList<Integer> array = new ArrayList<Integer>(); array.add(3); array.add(9); array.add(10); array.remove(1); array.set(0, 3); int num = array.get(1); System.out.println(array.size());
2
How many comparisons will the selection sort algorithm make on an array of 8 elements?
28
How do you create an ArrayList of Strings?
ArrayList<String> list = new ArrayList<String>();
What is a primary differences between an ArrayList and an Array?
Arrays have a fixed number of values, while ArrayLists can change in size.
What prints after this runs: ArrayList<String> breeds = new ArrayList<String>(); breeds.add("Saint"); breeds.add("Corgi"); breeds.add("Bulldog"); breeds.add("Frenchie"); String first = breeds.remove(0); String second = breeds.set(0, "Berner"); breeds.add(2, first); System.out.println("Breeds: " + second + " and " + breeds.get(1));
Breeds: Corgi and Bulldog
True or False: Because ArrayLists can only store object values, int and double values cannot be added to an ArrayList.
False
True or False: Enhanced for loops should not be used to traverse ArrayLists.
False
True or False: Linear Search becomes more efficient as more values are added to a particular data set.
False
How does Linear Search work?
Linear Search traverses an array until the desired value is found, or until the end of the array.
What is cybersecurity?
The field in computer science that's related to keeping data private and secure
What is phishing?
The fraudulent practice of sending emails purporting to be from reputable companies in order to induce individuals to reveal personal information, such as passwords and credit card numbers
True or False: every aspect of computing can have a negative impact on society
True
What is the standard method used to traverse an ArrayLists?
for(int index = 0; index < array.size(); index++) { array.get(index); }
Which is more secure, http or https?
https
What are protocols for data sharing on the internet?
rules and conventions for communication between network devices
What prints after this runs: ArrayList<Integer> array = new ArrayList<Integer>(); array.add(3); array.add(9); array.add(10); array.remove(1); array.set(0, 3); int num = array.get(1); System.out.println(num);
10
How does Selection Sort work to sort an array?
Selection Sort iterates through each index and swaps the current index with the minimum value that exists in the indices greater than the current index.
