Course Hero Logo

Unit 7 Review ArrayLists ANSWERS.pdf - AP Computer Science...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 18 pages.

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++;}}
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?
1

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 18 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Montague
Tags
English language films, Syntax highlighting, Run time, Compile time

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture