1/8
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What are methods of an object called? What do they consist of?
Accessors
Consists of getters or readers, as well as setters or writers
Accessors = Readers + Writers
Which is private and which is public when talking about objects?
Public interface = methods
Private interface = data values
Difference between a homogeneous and heterogeneous object?
Homogeneous: all of
its data values are of the same type
Heterogeneous = Data values have different types (i.e strings, int, double, etc)
How is an object used in java? What is an example of this?
(1) Define a class to specify the object’s look
and feel
(2) Create objects using the new operator
along with references
Date d1; = declaration of variable for type Date (the class), a reference
d1 = new Date(); creates the object
How do you add items to a list 9not an array)? What method is used?
Name an example.
When does add items fail?
add(i, newitem)
Add a new item at a certain position (i)
i.e add(2, spaghetti) in a string list makes spaghetti be in position 2 while pushing the original value lower, which shifts some of the list
This fails if “i” is negative or beyond the size of the list
How do you remove items from a list? Can there be gaps in lists? When will remove fail?
remove(i), i being position of the item
After the item is removed, the list is shifted to the left to reposition.
There cannot be gaps in lists
Fails when there are no items in a list or when “i” is out of range, so the value must be greater or equal to 0 or less than the list’s size
How to get data from a list? What happens if the list is empty?
get(i), gets item from integer position i, returning a copy of this item. Restricted to 0 <= i < size.
Get fails
What are the operations divided into for lists? Where are the types of operations?
Readers and writers
reader: an op that does not affect the contents
of the list
writer: an op that does affect the contents
readers: size, isEmpty, and get
writers: add, remove (think of remove as an eraser)