Previous QuizPrev Quiz
Generic Classes
Next QuizNext Quiz

Big Java Binder Early Objects

Computing

Quiz 18 :
Generic Classes

Quiz 18 :
Generic Classes

Showing 1 - 20 of 75
Next Quiz
arrow
Which of the following statements about generic programming is NOT correct?
Free
Multiple Choice
Answer:

Answer:

D

arrow
Which of the following statements about generic programming is NOT correct?
Free
Multiple Choice
Answer:

Answer:

C

arrow
Consider the following code snippet: ArrayList coins1 = new ArrayList(); //Line 1 LinkedList coins2 = new LinkedList(); //Line 2 Coins1.add("my penny"); //Line 3 Coins2.addFirst("my penny"); //Line 4 Which of the above lines will cause a compile-time error?
Free
Multiple Choice
Answer:

Answer:

C

arrow
Consider the following code snippet: ArrayList coins1 = new ArrayList(); //Line 1 LinkedList coins2 = new LinkedList(); //Line 2 Coins1.add("my penny"); //Line 3 Coins2.addFirst("my penny"); //Line 4 Which of the above lines will cause a run-time error when the object is retrieved elsewhere in the program?
Multiple Choice
Answer:
arrow
Consider the following code snippet: ArrayList accounts1 = new ArrayList(); //Line 1 LinkedList accounts2 = new LinkedList(); //Line 2 Accounts1.add("my Salary"); //Line 3 Accounts2.addFirst("my Salary"); //Line 4 Which of the above lines will cause a compile-time error?
Multiple Choice
Answer:
arrow
Consider the following code snippet: ArrayList accounts1 = new ArrayList(); //Line 1 LinkedList accounts2 = new LinkedList(); //Line 2 Accounts1.add("my Salary"); //Line 3 Accounts2.addFirst("my Salary"); //Line 4 Which of the above lines will cause a run-time error when the object is retrieved elsewhere in the program?
Multiple Choice
Answer:
arrow
Which of the following statements about using generic programming is NOT correct?
Multiple Choice
Answer:
arrow
Consider the following code snippet: ArrayList arr = new ArrayList(); String element = arr.get(0); Is there an error in this code?
Multiple Choice
Answer:
arrow
Which Java technique(s) allows generic programming? I type variables II primitive types III inheritance
Multiple Choice
Answer:
arrow
Which Java generic programming technique(s) requires the programmer to use casting to access variables stored as Object types? I type variables II primitive types III inheritance
Multiple Choice
Answer:
arrow
Which is the purpose of the element in the class declaration below? public class Thing { Public Thing() { . . . } }
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box() { . . . } } Which of the following choices is a specific type of the generic Box class?
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box(){ . . . } } Which of the following is a valid Box object instantiation?
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box(){ . . . } Public void insert(E value) { . . . } } Which of the following is a valid Box object instantiation? I Box box = new Box(); II Box box = new Box(); III Box box = new Box();
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box() { . . . } Public void insert(E value) { . . . } } What will result from executing the following code? Box box = new Box(); Box)insert("blue Box");
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box() { . . . } Public void insert(E value) { . . . } Public E getData() { . . . } } What will result from executing the following code? Box box = new Box(); Box b = (Box) box.getData();
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box(){ . . . } Public void insert(E value) { . . . } Public E getData() { . . . } } What will result from executing the following code? Box box = new Box(); ) . . Box)insert("blue Box"); String b = (String) box.getData();
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box(){ . . . } Public void insert(E value) { . . . } Public E getData(){ . . . } } What will result from executing the following code? Box box = new Box(); ) . . Box)insert("blue Box"); String b = (Object) box.getData();
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box() { . . . } Public void insert(E value) { . . . } Public E getData(){ . . . } } What will result from executing the following code? Box box = new Box(); ) . . Box)insert("blue Box"); String b = box.getData();
Multiple Choice
Answer:
arrow
Consider the following code snippet: public class Box { Private E data; Public Box() { . . . } Public void insert(E value) { . . . } Public E getData(){ . . . } } What will result from the following code? Box box = new Box(); ) . . Box)insert("blue Box"); Double myDouble = (Double) box.getData();
Multiple Choice
Answer:
Showing 1 - 20 of 75
Next Quiz