Arrays and Lists Mastery Quiz Quiz

  1. Array Traversal Question

    Which method is most commonly used to iterate through each element in an array, performing an operation on each?

    1. Reverse engineering
    2. Enhanced for loop
    3. Binary indexing
    4. Recursive descent
    5. Covariant arrays
  2. List Insertion Scenario

    In a linked list, what must be updated when inserting a new node in the middle of the list?

    1. Only the new node's value
    2. The size of arraylist.
    3. The autoboxing value of object
    4. The 'next' pointers of the preceding and new nodes
    5. Autocasting Generics
  3. Generic List Deletion

    What is the most important aspect to consider when deleting an element from a linked list to avoid memory leaks or broken lists?

    1. Autoboxing the type of the object
    2. Autocasting a string array
    3. Updating the 'lastAccessed' variable
    4. Updating references to 'Minima'
    5. Autoboxing requires to handle null
  4. Array Search Algorithm

    Which of the following search algorithms is NOT typically suitable for unsorted arrays?

    1. Linear Search
    2. For Each loop
    3. Sentinel Search
    4. Generics casting
    5. Binary Search
  5. Autoboxing Impact on Performance

    How does excessive autoboxing of primitive types affect performance in Java collections?

    1. Speeds up array creation
    2. Autoboxing has no effect
    3. Reduces memory allocation
    4. Increase run-time performance
    5. It can lead to increased memory usage and overhead
  6. Generics in Collections

    What primary benefit do generics provide when working with collections in Java?

    1. Solely for auto-casting
    2. Solely for covariance in arrays
    3. Discover type-mismatch errors at compile time instead of run time.
    4. Return arrays from methods which return an Iterable
    5. Breaks backward compatibility
  7. Covariant Arrays Defect

    Why are covariant arrays considered a defect in Java's type system by many programmers?

    1. Introduce new keywords and break backward compatibility
    2. Do not incur unnecessary run-time performance overhead
    3. Circumvent the problem that Java didn't originally include generics in its design
    4. Lead to ArrayStoreException
    5. Provide an easy way to create new array of a parameterized type
  8. Arrays Iterable

    Why can you not pass an array to a method that expects an Iterable in Java?

    1. Arrays are covariant
    2. Arrays are Iterable
    3. Arrays are iterable by design
    4. Strings are iterable
    5. Arrays are not Iterable
  9. Autoboxing True False

    Consider the following code: Integer b1 = 120; Integer b2 = 120; System.out.println(b1 == b2); Integer b3 = 200; Integer b4 = 200; System.out.println(b3 == b4); Why does the first group of statements print true, but the second false?

    1. Because b1 and b2 are references to different Integer objects.
    2. Java's implementation of valueOf() retrieves a cached values if the integer is between -128 and 127.
    3. It results in a run-time error.
    4. Primitive type can store every value of their corresponding wrapper type except null.
    5. Because arrays are covariant.
  10. Autoboxing Code Fragment

    How does autoboxing handle the following code fragment?

    1. It results in a run-time error.
    2. Primitive type can store every value of their corresponding wrapper type except null.
    3. ArrayStoreException
    4. Strings are iterable
    5. By redeclaring first