Finals Notes V Flashcards

(17 cards)

1
Q

How do you declare a NoNullArrayList?

A

public class NoNullArrayList < T > extends ArrayList < T > {}

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

How do you declare an OrderedArrayList?

A

public class OrderedArrayList< T extends Comparable< T» extends NoNullArrayList< T>

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

What is bubble sort? What is its worst case?

A
  • Goes through index x and x + 1 until end is reached
  • Worst case is n – 1 passes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Optimized Bubble Sort?

A

Uses swappedFlag to see if any swaps occur

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

What is selection sort? What is its worst case?

A
  • Selects first element as minimum
  • Changes what “minimum” is as comparisons continue
  • Worst case is n – 1 passes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is insertion sort?

A
  • Assumes that element at index 0 is sorted
  • Uses the second index as a key, then the third index, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does Math.random() do?

A

Returns a number from 0.0 to 1.0 (exclusively).

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

What are the formulas for printing a number between a (inclusive) and b (inclusive)?

A

(int) ((Math.random() * range) + min)
(rand.nextInt(range) + min)
Where range = max - min + 1

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

What are the formulas for printing a number between a (inclusive) and b (exclusive)?

A

(int) (Math.random() * range) + min)
(rand.nextInt(range) + min)
Where range = max - min

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

How do you declare a Random class?

A

Random rand = new Random();

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

What does String[] args do?

A

Allows a program to receive input from the command line

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

What is args used for?

A

A String array

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

What is abstraction?

A

Abstraction hides certain details and shows only the essential information to the user.

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

What are some characteristics of abstract classes?

A
  • Cannot create objects.
  • Must be inherited from another class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are abstract methods?

A
  • Can only be used in abstract classes
  • Does not have a body.
  • Subclasses will inherit and define the bodies.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When using interfaces, what replaces the word extends?

17
Q

What does an interface do?

A

States the necessary methods with no bodies.