ARRAY Flashcards

(32 cards)

1
Q

is a container object that holds a fixed number of values
of a single type.

A

array

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

The – of an array is established when the array is created. After creation, its – is fixed.

A

length, length

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

Array store – values of the same type.

A

multiple

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

Array uses —based indexing( first elements at index 0)

A

ZERO

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

Array has a – size, meaning it cannot grow or shrink –.

A

fixed, dynamically

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

Array elements are stored in – memory locations.

A

contiguous

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

Declare with –.

datatypes identifier[]={“val1”, “val2”, “val3”,…..”valn”};

A

values

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

Declare with –.

datatypes identifier[] = new datatype[size]

A

no values

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

Accessing and Modifying Array Elements use – to access elements (arr[index]).

A

indexing

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

Index starts from 0 and goes up to length –.

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

class is a resizable array, which can be found in the java.util package.

A

ArrayList

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

The difference between a built-in array and an ArrayList in Java, is that the
size of an array – (if you want to add or remove elements to/from
an array, you have to create a new one). While elements can be added and removed
from an ArrayList whenever you want.

A

cannot be modified

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

To access an element in the ArrayList, use the – method and refer to the index number

A

get()

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

To modify an element, use the – method and refer to the index number

A

set()

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

to remove an item, use the – method and refer to the index number: cars.remove(0);. To remove all the elements in the ArrayList, use the – method

A

remove(), clear()

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

– to find out how many elements an ArrayList have, use the –
method

17
Q

this is used to sort elements from a-z.

A

Collections.sort()

18
Q

is a sequence of character treated as single unit such as “Hello World”.

19
Q

String –, once a string is created it cannot be changed. None of its methods changes the string.

20
Q

The common way to create a string by using string – or using quotes and assign it in a variable;

21
Q

When the input type is not what the program expects.

A

InputMismatchException

22
Q

When you do invalid math operations, like dividing by zero.

A

ArithmeticException

23
Q

When you try to access an array index that doesn’t exist.

A

ArrayIndexOutOfBoundsException

24
Q

When you try to use an object that is null

A

NullPointerException

25
When you try to convert a string to a number, but the string isn’t a valid number.
NumberFormatException
26
Catch and handle errors gracefully Show a helpful message instead of crashing Keep the rest of your code running
try-catch
27
if you want something to always run (whether there’s an error or not)
finally Block
28
Code that might cause an error
try
29
Code that runs when an error happens
catch
30
A String in Java is an --(not a primitive type).
object
31
To use other types, such as int, you must specify an equivalent wrapper class: --.
Integer
32