Multiple Choice Questions:
1) An array can be classified as what type of object?
a) dynamic
b) linear
c) first-in first-out
d) heterogeneous
e) collection
2) A collection in which the items stored there are of different types is referred to as a(n) ______type.
a) homogeneous
b) heterogeneous
c) dynamic
d) abstract
e) ArrayList
3) Which of the following is considered an Abstract Data Type?
a) array
b) reference variable
c) any of the primitive types (e.g., int, double, char)
d) Stack
e) all of the above
4) Abstract Data Types have which of the following object-oriented features?
a) Information hiding
b) Inheritance
c) Polymorphism
d) Message Passing
e) All of the above
6. Which of the following interfaces would be used to implement a class that represents a group (or collection) of objects?
a) List
b) Speaker
c) Comparable
d) MouseListener
e) KeyListener
7) In order to implement Comparable in a class, what method(s) must be defined in that class?
a) Equals
b) Compares
c) both lessThan and greaterThan
d) compareTo
e) both compares and equals
True-False Questions:
1) _____An abstract class can be extended.
2) ____ An Abstract Data Type is a data structure, that is, it is the listing of the instance data and the visibility modifiers for those instance data.
3) ____The Abstract Data Type (ADT) is thought of as abstract because the operations that are to be implemented are separated from the actual implementation, that is, an ADT can be implemented in more than one way and that implementation is separate from how we might use the ADT.
4) _____An array is a List Abstract Data Type.
5) _____An abstract class can have instances
6) __To implement the ActionListener interface, you must implement the method actionPerformed.
7) ______Any class can implement an interface, but no classes can implement more than a single interface.
8) _____Abstract classes are placeholders that help organize information and provide a base for polymorphic references
Free Form
For questions 1 to 4, identify which of the following relationships is shared between the pair of objects:
a) uses
b) has-a
c) is-a
d) identity (that is, the two items are synonymous or equal)
e) no relationship
1.Student, GPA
2 Student, Pencil
3. Student, Teacher
4. Student, Graduate Student
7. Two collections types are the ordered list and the unordered list. Explain how these two collections are similar and how they will differ. To answer this question, assume that you do not know how they are implemented (that is, whether they are implemented using an array or a linked list). Answer in terms of the add, remove and search methods.
Add() ______
Delete ()
Contains() ______
8. What is the difference between a data structure and an Abstract Data Type
______
Big O Notation
1. Write an algorithm for the ArrayList that puts each new item in the first position of the array.
2. What is the Big O complexity of this algorithm ______
3. What is meant by the statement “f is O(n^2) ______
4 What is meant by the statement: “This algorithm runs in O(1) time”.
5. Other than time, name a factor which sometimes needs to be considered in
determining the complexity of an algorithm. ______
6. What is the time complexity to add an item to a collection set up for binary
searching. Explain
7. What is the time complexity of the following :
a) A loop that runs N times where N is the number of item to be processed
b) Creating a checkerboard
c) A loop like the following:
for(int i = 1; i < N; i = i * 2){} ______
for (int x = N; x > 0; x = x/2)
for(int i = 0; i < N; i = i + 1){} ______
C:\Users\chelwig\AppData\Local\Temp\Homework9.doc - 1 -