Arrays Flashcards

1
Q

A ________________ is a way of organizing and storing data so that it can be accessed and modified efficiently

A

data structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Arrays in Java are _______________ data structures, meaning they store elements of the same data type.

A

homogeneous

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A specific element in an array is accessed by its _________. In Java, array indices start from __

A

index, 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When an array is created, Java allocates a continuous __________________ to store its values

A

block of memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The ______________ is the total number of elements stored in an array, and in Java, you can get this using _____________

A

array length, .length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A one-dimensional array can be visualized as a _____.

A

row

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

During array construction, each element is initialized to a _________ value through a process called _________________.

A

default, auto-initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

TRUE or FALSE

You cannot directly initialize only part of an array in Java.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A common loop used for traversing arrays and accessing each element one by one is the __________.

A

for loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The enhanced for loop, also called the _______, simplifies array traversal without needing indices

A

for-each loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

TRUE or FALSE

You can modify array elements using for-each loop

A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Trying to access an index outside the valid range of an array will cause an _______________________________.

A

ArrayIndexOutOfBoundsException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

TRUE or FALSE

Once an array is created, its size cannot be changed

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

___________ is used if dynamuc resizing is needed.

A

ArrayList

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

TRUE or FALSE

The Arrays class provides non-static methods to perform common array operations

A

FALSE, static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The Arrays.sort() method sorts an array in _________________.

A

ascending order

13
Q

The Arrays.equals() method checks if two arrays contain the same ___________ in the same ________.

A

elements, order

14
Q

Which of the following is NOT a limitation of arrays in Java according to the provided text?

a) Fixed size limitation
b) Inefficient for insertions/deletions
c) Requires manual sorting/searching
d) Can automatically resize

A

d) Can automatically resize

15
Q

What is the index of the first element in a Java array?

a) 1
b) 0
c) -1
d) The array’s length

16
Q

What is the default value assigned to elements of a boolean array upon initialization?

a) true
b) false
c) null
d) 0

17
Q

Which method from the Arrays class is used to create a new array with the same elements as an original array?

a) Arrays.fill()
b) Arrays.toString()
c) Arrays.copyOf()
d) Arrays.sort()

A

c) Arrays.copyOf()

18
Q

Which type of loop is best suited for modifying elements within an array?

a) Enhanced for loop (for-each)
b) while loop
c) Traditional for loop
d) do-while loop

A

c) Traditional for loop

19
Q

The position of an element inside an array; in Java, it starts from 0.

20
Q

A runtime error that occurs when trying to access an array element at an invalid position.

A

ArrayIndexOutOfBoundsException

21
Q

A data structure that stores one or more values of a specific data type under a single variable name, providing indexed access.

22
Q

The process where each element in an array is assigned a default value when the array is created.

A

Auto-initialization

23
Q

A Java utility class that provides static methods for common array operations like sorting, searching, and copying.

A

Arrays class

24
Q

A loop construct that allows you to iterate through an array without explicitly managing indices, primarily used for read-only access.

A

Enhanced for loop (for-each)

25
Q

The property of an array that represents the total number of elements it can hold.

A

Array length

26
Q

A type of array that can be visualized as a row of elements.

A

Single Dimensional Array (1D Array)

27
Q

A method used to search for an element in a sorted array efficiently, often returning a negative value if the element is not found.

A

Arrays.binarySearch()