Java Reference
In-Depth Information
15. Given the following class definition:
1. import java.io.*;
2.
3. public class Helper {
4. public static <U extends Exception> void
printException(U u) {
5. System.out.println(u.getMessage());
6. }
7.
8. public static void main(String [] args) {
9. ___________________
10. }
11. }
which of the following statements can appear on line 9 so that the Helper class
compiles successfully?
A. Helper.printException(new FileNotFoundException(“A“));
B. Helper.printException(new Exception(“B“));
C. Helper.<Throwable>printException(new Exception(“C“));
D. Helper.<NullPointerException>printException(new NullPointerException
(“D“));
E. Helper.printException(new Throwable(“E“));
16. Given the following class definition:
1. import java.util.*;
2.
3. public class Wildcard {
4. public void showSize(List<?> list) {
5. System.out.println(list.size());
6. }
7.
8. public static void main(String [] args) {
9. Wildcard card = new Wildcard();
10. ___________________
11. card.showSize(list);
12. }
13. }
Search WWH ::




Custom Search