Chapter 19 Flashcards
Fill in the code in Comparable______ c = new Date();
C.Date
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());
A.
list.add(“Red”);
To declare a class named A with two generic types, use
B. public class A -E, F- (Brackets, no parenthesis)
To declare an interface named A with a generic type, use A. public interface A { ... } B. public interface A { ... } C. public interface A(E) { ... } D. public interface A(E, F) { ... }
A.
public interface A -E- (Brackets, no parenthesis)
To declare an interface named A with two generic types, use A. public interface A { ... } B. public interface A { ... } C. public interface A(E) { ... } D. public interface A(E, F) { ... }
B.
public interface A -E, F- (Brackets, no parenthesis)
To create a list to store integers, use
A. ArrayList list = new ArrayList<>(); B. ArrayList list = new ArrayList<>(); C. ArrayList list = new ArrayList(); D. ArrayList list = new ArrayList<>();
B.Integer (in brackets)
To create a generic type bounded by Number, use
A.E extends number
Which of the following declarations use raw type?
D. ArrayList list = new ArrayList();
If you use the javac command to compile a program that contains raw type, what would the compiler do?
A. report syntax error B. report warning and generate a class file C. report warning without generating a class file D. no error and generate a class file E. report warning and generate a class file if no other errors in the program.
E. report warning and generate a class file if no other errors in the program.
If you use the javac ?Xlint:unchecked command to compile a program that contains raw type, what would the compiler do?
A. report compile error B. report warning and generate a class file C. report warning without generating a class file D. no error and generate a class file
B. report warning and generate a class file
Is ArrayList a subclass of ArrayList? A. Yes B. No
B. No
Is ArrayList a subclass of ArrayList>? A. Yes B. No
A. Yes
Is ArrayList a subclass of ArrayList extends Number>? A. Yes B. No
A. Yes
Is ArrayList a subclass of ArrayList extends Number>? A. Yes B. No
A. Yes
Is ArrayList> same as ArrayList extends Object>?
A. Yes B. No
A. Yes