VN4.1 ArrayList (Managing a set of Objects)
Short Answers (one line, one or two sentences, a small list)
- How do you access the java api?
- What classes are located in java.util?
- How do you import all classes in this package?
- How do you import only the ArrayList class?
- Look up the ArrayList class in the API, write the method signatures for methods you might use when managing a collection of objects.
- Approximately how many classes are provided with the Java class library
- Packages could be said to conform to the Software Engineering notion of cohesion, explain.
- What happens if you forget to instantiate an ArrayLIst object before you start to use it?
- Provide examples of code that would cause a NullReferenceexception to occur.
- What happens in your program when a NullRefernceException is generated?
- What does APi stand for?
Longer answers expected, half to one page.
- Is cohesion a notion that should be applied to class design as well? Explain
- List five packages that may be of interest to you, describe in general terms what area of java programming the classes address.
- Find a link to the Util package in the Java API, identify 4 different ways of storing lists/sets of objects. Describe the distinctive features of each class you identified.
VN4.2
Auction Bid behaviour
Longer answers expected, half to one page.
- Quality of a class can be based on the cohesion or class members. Explain would we look for when checking the quality of a class.
- Draw a class diagram from another program showing the relationship between two classes where objects of one class manage a collection of objects of another class.
Short Answers (one line, one or two sentences, a small list, a method)
- Examine the show lots method
- Does this method adhere to the deign principle of separating the user interface code from the program (Buisness) logic)? Explain
- On of the most common patterns of behaviour that you will find in OO programs in one that has one object looking after a collection of other objects.
- Which object is holding a collectionof other objects?
- Where is the ArrayList instantiated?
- What does it mean for the ArrayList to be typed?
- Is the code safer because the ArrayList is typed?
- Which method(s) add items to the collection?
- Which methods finds items in the collection?
- Which method deletes items in the collection?
- Write a method to delete a lot from the collection.
- Write a method to delete all items in the collection.
- Can this code be made safer? Where and how? Think about what would break the code.
VN4.3 Iteration, Alternatives (8.5mins)
Short Answers (one line, one or two sentences, a small list, a method)
- What does it mean to iterate through a list?
- What is an iterator? Provide code example.
- How do you use an iterator? Provide code example.
- When is it important to use an iterator?
- How do you obtain an iterator for an array list? Provide code example.
- How are iterators typed and why? Provide code example and explain.
- List four different ways to iterate through a collection. Provide code example.
- How does the String class “equals” method check equality?
- What is a sentinel value and how is this relevant to looping through a collection? Code example and explanation.
- What would happen if wanted was null in the music organizer?
- How could you make this(10) code safer?