Short Answers (One Line, One Or Two Sentences, a Small List)

Short Answers (One Line, One Or Two Sentences, a Small List)

VN4.1 ArrayList (Managing a set of Objects)

Short Answers (one line, one or two sentences, a small list)

  1. How do you access the java api?
  1. What classes are located in java.util?
  1. How do you import all classes in this package?
  1. How do you import only the ArrayList class?
  1. Look up the ArrayList class in the API, write the method signatures for methods you might use when managing a collection of objects.
  1. Approximately how many classes are provided with the Java class library
  1. Packages could be said to conform to the Software Engineering notion of cohesion, explain.
  1. What happens if you forget to instantiate an ArrayLIst object before you start to use it?
  1. Provide examples of code that would cause a NullReferenceexception to occur.
  1. What happens in your program when a NullRefernceException is generated?
  1. What does APi stand for?

Longer answers expected, half to one page.

  1. Is cohesion a notion that should be applied to class design as well? Explain
  2. List five packages that may be of interest to you, describe in general terms what area of java programming the classes address.
  3. 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.

  1. 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.
  2. 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)

  1. Examine the show lots method
  2. Does this method adhere to the deign principle of separating the user interface code from the program (Buisness) logic)? Explain
  1. 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.
  2. Which object is holding a collectionof other objects?
  3. Where is the ArrayList instantiated?
  4. What does it mean for the ArrayList to be typed?
  5. Is the code safer because the ArrayList is typed?
  6. Which method(s) add items to the collection?
  7. Which methods finds items in the collection?
  8. Which method deletes items in the collection?
  9. Write a method to delete a lot from the collection.
  10. Write a method to delete all items in the collection.
  11. 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)

  1. What does it mean to iterate through a list?
  2. What is an iterator? Provide code example.
  3. How do you use an iterator? Provide code example.
  4. When is it important to use an iterator?
  5. How do you obtain an iterator for an array list? Provide code example.
  6. How are iterators typed and why? Provide code example and explain.
  7. List four different ways to iterate through a collection. Provide code example.
  8. How does the String class “equals” method check equality?
  9. What is a sentinel value and how is this relevant to looping through a collection? Code example and explanation.
  10. What would happen if wanted was null in the music organizer?
  11. How could you make this(10) code safer?