Topical Information
This set of questions should help you firm up your knowledge of the Java
array-like
containers.
Questions
- Do Review Exercise R7.1.
- Do Review Exercise R7.2.
- Do Review Exercise R7.3.
- Do Review Exercise R7.4.
- Do Review Exercise R7.5.
- Do Review Exercise R7.6.
- Do Review Exercise R7.7.
- Do Review Exercise R7.8. (You can stop after the first sentence. I
believe this is an example of editorial leavage. (Although it is not
listed on the errata
page. *shrug*))
- Do Review Exercise R7.9.
- Do Review Exercise R7.10. (Even if you didn't have a debugger, you could
simply print the elements in question to the screen to see their initial
contents. However, you have access to the Data Display Debugger —
ddd
— on mars.) (My apologies to The University of Wisconsin Madison's CS
department for the theft of this fine link...)
- Do Review Exercise R7.11.
- Do Review Exercise R7.12.
- Do Review Exercise R7.13.
- Do Review Exercise R7.14.
- Do Review Exercise R7.15.
- Do Review Exercise R7.16.
- Do Review Exercise R7.17. (I wouldn't call them poor programming, just
not necessarily as enlightened. They are still useful in languages where
cla... Oops! I
almost gave it away. *whew*)
- Do Review Exercise R7.18.
- This space reserved to add more questions...maybe...
This question set is worth (Level
6).
Optional Questions
Do any of the following for an additional (Level
1) each.
- Do Review Exercise R7.19 as a small (1-2 page) paper.
- Do Review Exercise R7.20 as a small (1-2 page) paper.
- A method that has an array list as a parameter can change the contents in
two ways. It can change the contents of individual array elements or it
can rearrange the elements. Describe two useful methods with ArrayList<BankAccount> parameters that change an array list of
BankAccount objects in each of the two ways
just described. (That is, one method modifies the individual elements and
the other rearranges the elements.)
- Give an example of:
- A useful method that has an array of integers as a parameter that
is not modified.
- A useful method that has an array of integers as a parameter that
is modified.
- A useful method that has an array of integers as a return
value.
Describe each method; don't implement the methods.
- How do you perform the following tasks with arrays in Java?
- Test that two arrays contain the same elements in the same
order.
- Copy one array to another.
- Fill an array with zeroes, overwriting all elements in it.
- Remove all elements from an array list.
- True or false?
- A method cannot return a two-dimensional array.
- A method can change the length of an array parameter.
- A method can change the length of an array list that is passed as a
parameter.
- An array list can hold values of any type.