Test 1 review Flashcards

1
Q

abstract classes are used for…

A

setting up methods for subclasses

declaring private data fields

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

abstract method

A

method that has no body

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

can objects be created in abstract classes?

A

no

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

what overrides abstract methods?

A

concrete methods

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

how many interfaces can a class extend?

A

one

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

how many interfaces can a class implement?

A

multiple

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

interfaces contain

A

abstract methods

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

what’s a type?

A

a collection of values

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

simple type example

A

integer

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

aggregate type example

A

bank account

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

data item

A

piece of info drawn from a type

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

what does a data structure do?

A

implement an ADT

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

how does remove() work in a linked bag?

A

removes first item

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

if node is in a package what must it define?

A

set and get methods

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

removing the first node

A

set firstNode to reference the second node

decrement the number of entries

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

removing a node that isn’t first

A

move the firstNode to the removed nodes spot
set firstNode to reference the second node
decrement the number of entries

17
Q

pros and cons of using arrays

A
pros:
adding and removing entries is fast
cons:
takes time to remove a SPECIFIC entry
takes time to copy entries when increasing size
18
Q

how are entries removed in arrays?

A

the last element becomes null and takes the spot of the removed element

19
Q

package

A

collection of classes

20
Q

pros and cons of using chains

A

pros:
flexible size
can remove and recycle nodes
adding entries to the beginning and end is simple
cons:
removing a specific entry requires searching
uses more memory than arrays

21
Q

scope of a variable

A

section of the code in which the variable is visible

22
Q

A class uses composition when it

A

declares an instance of another class as a data field

23
Q

abstraction

A

focus on what and not on how

24
Q

what can bags NOT do?

A

reorder items

25
limitation of adding an item to a bag
you CANNOT specify where it goes
26
cons of fixed arrays
wastes memory limited capacity cannot expand when full
27
how does remove() work on fixed arrays?
it removes the last entry
28
the first node is also called the
head reference
29
access modifiers
public private protected
30
what does "protected" mean?
accessible by the classes of the same package and the subclasses residing in any package
31
is an interface a class?
NO