AP Computer ScienceName________________________________Date_________REVIEW Unit 6B ArrayListsChapter 71) Which statements are true regarding the differences between arrays and array lists?I. Arrays are better if the size of a collection will not changeII. Array lists are more efficient than arraysIII. Array lists are easier to use than arraysa) I, IIb) I, IIIc) II, IIId) I, II, IIIAnswer: B
2) What is the value of thecountvariable after the execution of the given code snippet?ArrayList<Integer> num = new ArrayList<Integer>();num.add(4);num.add(3);num.add(5);int count = 0;for (int i = 0; i < num.size(); i++){if (num.get(i) % 2 != 0){count++;}}
Get answer to your question and much more
3) Consider the following code snippet:public static void check(ArrayList<Integer> chknum1){int cnt = 0;for(int i = 0; i < chknum1.size(); i++){if(chknum1.get(i) == 0){cnt++;}}System.out.println("The total 0 values in the list are: " + cnt);}Which one of the following is true about thecheckmethod in the given code snippet?
Get answer to your question and much more