Question
QUESTION 1 Which of the following statements is correct? (Mark all that are correct.) a. Generics can avoid cumbersome castings. b. Generics can help detect
QUESTION 1 Which of the following statements is correct? (Mark all that are correct.) a. Generics can avoid cumbersome castings. b. Generics can help detect type errors at compile time, thus make programs more robust. c. Generics can make programs run faster. d. Generics can make programs easy to read. 7 points QUESTION 2 Fill in the code in Comparable ________ c = new Date(); a. b. c. d. 7 points QUESTION 3 Suppose ArrayListlist = new ArrayList<>(). Which of the following statements are correct? a. list.add(5.5); // 5.5 is automatically converted to new Double(5.5) b. list.add(3.0); // 3.0 is automatically converted to new Double(3.0) c. Double doubleObject = list.get(0); // No casting is needed d. double d = list.get(1); // Automatically converted to double e. all of the above f. a, b, & d 7 points QUESTION 4 Suppose List list = new ArrayList(). Which of the following operations would work with this declaration? (Mark all that apply.) a. list.add(new java.util.Date()); b. list.add(new Integer(100)); c. list.add("Red"); d. list.add; 7 points QUESTION 5 Suppose List list = new ArrayList(). Which of the following operations would work with this declaration? (Mark all that apply.) a. list.add("Red"); b. list.add(new java.util.Date()); c. list.add(new Integer(100)); d. list.add; 7 points QUESTION 6 To declare a class named A with one generic type, use a. public class A { ... } b. public class A { ... } c. public class A(E, F) { ... } d. public class A { ... } e. public class A(E) { ... } 6.5 points QUESTION 7 To declare a class named A with two generic types, use a. public class A(E) { ... } b. public class A { ... } c. public class A(E, F) { ... } d. public class A { ... } 6.5 points QUESTION 8 To declare an interface named A with a generic type, use a. public interface A { ... } b. public interface A(E) { ... } c. public interface A { ... } d. public interface A(E, F) { ... } 6.5 points QUESTION 9 To declare an interface named A with two generic types, use a. public interface A { ... } b. public interface A { ... } c. public interface A(E, F) { ... } d. public interface A(E) { ... } 6.5 points QUESTION 10 To create a list to store integers, use a. ArrayList list = new ArrayList<>(); b. ArrayList list = new ArrayList(); c. ArrayListlist = new ArrayList<>(); d. ArrayList list = new ArrayList<>(); 6.5 points QUESTION 11 The generic method's header is left blank in the highlighted section of 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 (String[ ] list) b. public static void print (int[ ] list) c. public static void print (E [ ] list) d. public static void print (Integer[ ] list) 6.5 points QUESTION 12 To create a generic type bounded by Number, use a. b. c. d. 6.5 points QUESTION 13 Which of the following declarations use raw type? a. ArrayList list = new ArrayList(); b. ArrayList list = new ArrayList<>(); c. ArrayListlist = new ArrayList<>(); d. ArrayList list = new ArrayList<>(); 6.5 points QUESTION 14 ArrayList and ArrayList are two types. Does the JVM load two classes ArrayList and ArrayList? (True = Yes, False = No) True False 6.5 points QUESTION 15 Generic type information is present at compile time. True False
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started