zuai-logo

Home

Leaderboard

    Learn
zuai-logo
  1. AP Computer Science A
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

Why are ArrayLists more versatile than arrays?

ArrayLists are dynamic in size, allowing addition and removal of elements.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

Why are ArrayLists more versatile than arrays?

ArrayLists are dynamic in size, allowing addition and removal of elements.

What is the purpose of the size() method in ArrayLists?

Returns the number of elements currently in the ArrayList.

Why must ArrayLists store objects instead of primitive types?

ArrayLists are designed to hold objects; primitive types must be wrapped in their corresponding class.

What is the significance of the import java.util.ArrayList; statement?

It makes the ArrayList class available for use in your Java code.

Explain the concept of traversing an ArrayList.

Iterating through each element of the ArrayList to perform an operation.

What is the purpose of searching in an ArrayList?

To find a specific element within the ArrayList.

What is the purpose of sorting an ArrayList?

To arrange the elements of the ArrayList in a specific order.

What is the ethical consideration when collecting user data?

Protecting user privacy and using data responsibly.

What does it mean for an ArrayList to be 'dynamic'?

Its size can change during runtime; elements can be added or removed.

Why is transparency important regarding data collection?

Builds trust with users and allows them to make informed decisions.

How is ArrayList used in real-world scenarios?

Storing a list of customers in a database or managing a playlist of songs.

How is linear search applied in real-world scenarios?

Finding a specific product in a small inventory list.

How is selection sort applied in real-world scenarios?

Sorting a small list of student names alphabetically.

How is insertion sort applied in real-world scenarios?

Sorting a hand of cards as you receive them in a card game.

How is encryption used to protect user data?

Securing online transactions and protecting sensitive information from hackers.

Give a real-world example of ethical data collection.

A research study that obtains informed consent from participants before collecting their data.

How are ArrayLists used in social media applications?

Storing lists of friends, posts, or comments.

How are ArrayLists used in e-commerce applications?

Managing shopping carts and product lists.

How is data collection used in healthcare?

Tracking patient health records and monitoring disease outbreaks.

How is data collection used in education?

Tracking student performance and personalizing learning experiences.

What are the differences between ArrayLists and arrays?

ArrayLists: Dynamic size, use methods | Arrays: Fixed size, use bracket notation

What are the differences between selection sort and insertion sort?

Selection Sort: Finds minimum and swaps | Insertion Sort: Inserts elements into correct position

What are the differences between using a for loop and a for-each loop to traverse an ArrayList?

For loop: Uses index, can modify | For-each loop: No index, cannot modify

What are the differences between add(E obj) and add(int index, E obj) in ArrayLists?

add(E obj): Appends to the end | add(int index, E obj): Inserts at a specific index

What are the differences between get(int index) and set(int index, E obj) in ArrayLists?

get(int index): Retrieves element at index | set(int index, E obj): Updates element at index

What are the differences between using primitive types and wrapper classes in ArrayLists?

Primitive types: Cannot be stored directly | Wrapper classes: Can be stored in ArrayLists

What are the differences between searching and sorting?

Searching: Locates a specific element | Sorting: Arranges all elements in order

What are the differences between arrays and ArrayLists in terms of memory usage?

Arrays: Allocate fixed memory | ArrayLists: Dynamically allocate memory, potentially more overhead

What are the differences between the best-case time complexity of selection sort and insertion sort?

Selection Sort: O(n^2) | Insertion Sort: O(n)

What are the differences between the worst-case time complexity of selection sort and insertion sort?

Selection Sort: O(n^2) | Insertion Sort: O(n^2)