Java Arrays Flashcards

1
Q

What are issues with arrays?

A

The java array does not allow you to add elements. And It can waste the amount of memory. When you set up an array you will allocate some memory space for the amount in the array.

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

One key item to remember

A

When you are constructing a data element or anything in java, memory will be allocated and placeholders will be displayed. This is why it is important to when looking at performance of an application.

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

What is the syntax for the for each method?

A

for (type var : array)
{
statements using var;
}

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

What is a stack?

A
The stack class represents a last in first out stack of objects.
it extends the vector class
Vector is similar to ArrayList, difference being vector methods are synchronized whereas ArrayList methods are not.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the methods to add and remove items from a stack?

A

Push and Pop

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

What is a linked list?

A

All of the nodes are linked together and then can access the address on the next node , One thing to think about it memory efficiency and performance. Linked list will remove items and then will remove the item from the memory.

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

List interface…

A

It is the main interface that is used to modify the Array List . The syntax is List countries = new ArrayList<>(). You will notice that the List interface is the type on the left and the ArrayList is the type on the right.

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

What are some advantages of iterator?

A

It has more methods that are helpful to go to go through loops.

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

what is the compareTo method

A
It is to compare strings or objects.  or data types 
example:
Integer x = 3;
Integer y =2;
x.compareTo(y);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is one popular method of Iterator?

A

hasNext() it will determine if there are more elements in the iterator and if there are then it will continue.

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

What is one common method for collections?

A

One method is the sort method and can sort collections.

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