Test 1 review Flashcards
abstract classes are used for…
setting up methods for subclasses
declaring private data fields
abstract method
method that has no body
can objects be created in abstract classes?
no
what overrides abstract methods?
concrete methods
how many interfaces can a class extend?
one
how many interfaces can a class implement?
multiple
interfaces contain
abstract methods
what’s a type?
a collection of values
simple type example
integer
aggregate type example
bank account
data item
piece of info drawn from a type
what does a data structure do?
implement an ADT
how does remove() work in a linked bag?
removes first item
if node is in a package what must it define?
set and get methods
removing the first node
set firstNode to reference the second node
decrement the number of entries
removing a node that isn’t first
move the firstNode to the removed nodes spot
set firstNode to reference the second node
decrement the number of entries
pros and cons of using arrays
pros: adding and removing entries is fast cons: takes time to remove a SPECIFIC entry takes time to copy entries when increasing size
how are entries removed in arrays?
the last element becomes null and takes the spot of the removed element
package
collection of classes
pros and cons of using chains
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
scope of a variable
section of the code in which the variable is visible
A class uses composition when it
declares an instance of another class as a data field
abstraction
focus on what and not on how
what can bags NOT do?
reorder items