Name:_______________________



Name:_______________________

Covers Chs 21-25 |Sample Exam | |

Part I: Questions: (1 pts each)

1. ________ is a data structure to store data in sequential order.

a. A list

b. A set

c. A tree

d. A stack

e. A queue

2. A __________ (with no duplicate elements) has the property that for every node in the tree the value of any node in its left subtree is less than the value of the node and the value of any node in its right subtree is greater than the value of the node.

a. binary tree

b. binary search tree

c. list

d. linked list

3. The ________ is to visit the left subtree of the current node first, then the current node itself, and finally the right subtree of the current node.

a. inorder traversal

b. preorder traversal

c. postorder traversal

d. breadth-first traversal

4. The _________ is to visit the nodes level by level. First visit the root, then all children of the root from left to right, then grandchildren of the root from left to right, and so on.

a. inorder traversal

b. preorder traversal

c. postorder traversal

d. breadth-first traversal

5. To remove the root, you need to start a process by first placing _______ to the place of the root and move it down to maintain the heap property.

a. one of the root's children

b. the larger child of the root

c. the smaller child of the root

d. the last node in the heap

6. To add a new node, you need to start a process by first placing it as _______ and move it up to main the heap property.

a. the new root

b. the last node in the heap

c. the left child of the root

d. the right child of the root

7. Which data structure is appropriate to store patients in an emergency room?

a. Stack

b. Queue

c. Priority Queue

d. Linked List

8. Which data structure is appropriate to store customers in a clinic for taking flu shots?

a. Stack

b. Queue

c. Priority Queue

d. Array List

e. Linked List

9. Fill in the code in Comparable______ c = new Date();

a.

b.

c.

d.

10. Suppose List list = new ArrayList. Which of the following operations are correct?

a. list.add("Red");

b. list.add(new Integer(100));

c. list.add(new java.util.Date());

d. list.add(new ArrayList());

11. To declare a class named A with two generic types, use

a. public class A { ... }

b. public class A { ... }

c. public class A(E) { ... }

d. public class A(E, F) { ... }

12. The method header is left blank in the following code. Fill in the header.

public class GenericMethodDemo {

public static void main(String[] args ) {

Integer[] integers = {1, 2, 3, 4, 5};

String[] strings = {"London", "Paris", "New York", "Austin"};

print(integers);

print(strings);

}

__________________________________________ {

for (int i = 0; i < list.length; i++)

System.out.print(list[i] + " ");

System.out.println();

}

}

a. public static void print(Integer[] list)

b. public static void print(String[] list)

c. public static void print(int[] list)

d. public static void print(Object[] list)

13. To create a generic type bounded by Number, use

a.

b.

c.

d.

14. Which of the following declarations use raw type?

a. ArrayList list = new ArrayList();

b. ArrayList list = new ArrayList();

c. ArrayList list = new ArrayList();

d. ArrayList list = new ArrayList();

Key:d

15. Is ArrayList a subclass of ArrayList?

a. true

b. false

16. Is ArrayList a subclass of ArrayList?

a. true

b. false

17. Does ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download