Make a parody of a hiphop song in order to cover these statements[(java) VAR-2.A.1 The…
- User
Make a parody of a hiphop song in order to cover these statements[(java) VAR-2.A.1 The use of array objects allows multiple related items to be represented using a single variable. VAR-2.A.2 The size of an array is established at the time of creation and cannot be changed. VAR-2.A.3 Arrays can store either primitive data or object reference data. VAR-2.A.4 When an array is created using the keyword new, all of its elements are initialized with a specific value based on the type of elements: § Elements of type int are initialized to 0 § Elements of type double are initialized to 0.0 § Elements of type boolean are initialized to false § Elements of a reference type are initialized to the reference value null. No objects are automatically created VAR-2.A.5 Initializer lists can be used to create and initialize arrays. VAR-2.A.6 Square brackets ([ ]) are used to access and modify an element in a 1D array using an index. VAR-2.A.7 The valid index values for an array are 0 through one less than the number of elements in the array, inclusive. Using an index value outside of this range will result in an ArrayIndexOutOfBoundsException being thrown. VAR-2.B.1 Iteration statements can be used to access all the elements in an array. This is called traversing the array. VAR-2.B.2 Traversing an array with an indexed for loop or while loop requires elements to be accessed using their indices. VAR-2.B.3 Since the indices for an array start at 0 and end at the number of elements −1, “off by one” errors are easy to make when traversing an array, resulting in an ArrayIndexOutOfBoundsException being thrown. VAR-2.C.1 An enhanced for loop header includes a variable, referred to as the enhanced for loop variable. VAR-2.C.2 For each iteration of the enhanced for loop, the enhanced for loop variable is assigned a copy of an element without using its index. VAR-2.C.3 Assigning a new value to the enhanced for loop variable does not change the value stored in the array. VAR-2.C.4 Program code written using an enhanced for loop to traverse and access elements in an array can be rewritten using an indexed for loop or a while loop. CON-2.I.1 There are standard algorithms that utilize array traversals to: § Determine a minimum or maximum value § Compute a sum, average, or mode § Determine if at least one element has a particular property § Determine if all elements have a particular property § Access all consecutive pairs of elements § Determine the presence or absence of duplicate elements § Determine the number of elements meeting specific criteria CON-2.I.2 There are standard array algorithms that utilize traversals to: § Shift or rotate elements left or right § Reverse the order of the elements VAR-2.D.1 An ArrayList object is mutable and contains object references. VAR-2.D.2 The ArrayList constructor ArrayList() constructs an empty list. VAR-2.D.3 Java allows the generic type ArrayList, where the generic type E specifies the type of the elements. VAR-2.D.4 When ArrayList is specified, the types of the reference parameters and return type when using the methods are type E. VAR-2.D.5 ArrayList is preferred over ArrayList because it allows the compiler to find errors that would otherwise be found at run-time. VAR-2.D.6 The ArrayList class is part of the java. util package. An import statement can be used to make this class available for use in the program. VAR-2.D.7 The following ArrayList methods— including what they do and when they are used—are part of the Java Quick Reference: § int size()- Returns the number of elements in the list § boolean add(E obj)-Appends obj to end of list; returns true § void add(int index, E obj)- Inserts obj at position index (0 <= index <= size), moving elements at position index and higher to the right (adds 1 to their indices) and adds 1 to size § E get(int index)-Returns the element at position index in the list § E set(int index, E obj)— Replaces the element at position index with obj; returns the element formerly at position index § E remove(int index)—Removes element from position index, moving elements at position index + 1 and higher to the left (subtracts 1 from their indices) and subtracts 1 from size; returns the element formerly at position index VAR-2.E.1 Iteration statements can be used to access all the elements in an ArrayList. This is called traversing the ArrayList. VAR-2.E.2 Deleting elements during a traversal of an ArrayList requires using special techniques to avoid skipping elements. VAR-2.E.3 Since the indices for an ArrayList start at 0 and end at the number of elements − 1, accessing an index value outside of this range will result in an IndexOutOfBoundsException being thrown. VAR-2.E.4 Changing the size of an ArrayList while traversing it using an enhanced for loop can result in a ConcurrentModificationException being thrown. Therefore, when using an enhanced for loop to traverse an ArrayList, you should not add or remove elements. CON-2.J.1 There are standard ArrayList algorithms that utilize traversals to: § Insert elements § Delete elements § Apply the same standard algorithms that are used with 1D arrays CON-2.J.2 Some algorithms require multiple String, array, or ArrayList objects to be traversed simultaneously CON-2.K.1 There are standard algorithms for searching. CON-2.K.2 Sequential/linear search algorithms check each element in order until the desired value is found or all elements in the array or ArrayList have been checked. CON-2.L.1 Selection sort and insertion sort are iterative sorting algorithms that can be used to sort elements in an array or ArrayList. CON-2.M.1 Informal run-time comparisons of program code segments can be made using statement execution counts ].
- Assistant