Java题库11
1.
?
(1)<? super String>?is any class which is a?superclass?of?String?(including?String?itself). (In this case, the only other suitable class is?Object.)
即包括String的父類和它本身的類。
(2)?<? extends String>?(which in this specific case wouldn't be very useful as?String?is?final, so it can have no subclasses).
即包括String的子類,而String沒有子類,為null。
2
comparator是實現compare方法
comparable是實現compareto方法
3.
理論上subSet出來的Set只要你add進去的數在你subSet時候指定的區間之內就不會拋出異常了,你用jdk 1.6試試?
4.
我遇到的情況是直接List<String> list=new ArrayList();
在這種情況下,我們如果調用Collections.sort(list);方法,它會對list里字符串從左往右的字母的ascii值進行排序,不用實現 Comparator 接口
5.
public classBreaker2 {
2. ? staticString o= "";
3.
4. ? public static voidmain(String[] args) {
5. z: for(intx = 2; x < 7; x++) {
6. ? if(x == 3)
7. ? continue;
8. ? if(x == 5)
9. ? breakz;
10. ?o= o+ x;
11.}
12.System.out.println(o);
13.}
14.}
輸出24
如果把continue改為break就會出錯
6.
變量 不管你寫什么 最后都是 public static final
方法 不管你寫什么 最后都是 public abstract
接口里的東四 都是 public的
實現接口必須是public的
7.
Which can appropriately be thrown by a programmer using Java SE technology to create a desktopapplication?
A. ClassCastException
B. NullPointerException
C. NoClassDefFoundError
D. NumberFormatException
E. ArrayIndexOutOfBoundsException
Answer: D
總結
- 上一篇: java题库10
- 下一篇: Java虚拟机的体系结构