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的父類(lèi)和它本身的類(lèi)。
(2)?<? extends String>?(which in this specific case wouldn't be very useful as?String?is?final, so it can have no subclasses).
即包括String的子類(lèi),而String沒(méi)有子類(lèi),為null。
2
comparator是實(shí)現(xiàn)compare方法
comparable是實(shí)現(xiàn)compareto方法
3.
理論上subSet出來(lái)的Set只要你add進(jìn)去的數(shù)在你subSet時(shí)候指定的區(qū)間之內(nèi)就不會(huì)拋出異常了,你用jdk 1.6試試?
4.
我遇到的情況是直接List<String> list=new ArrayList();
在這種情況下,我們?nèi)绻{(diào)用Collections.sort(list);方法,它會(huì)對(duì)list里字符串從左往右的字母的ascii值進(jìn)行排序,不用實(shí)現(xiàn) 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就會(huì)出錯(cuò)
6.
變量 不管你寫(xiě)什么 最后都是 public static final
方法 不管你寫(xiě)什么 最后都是 public abstract
接口里的東四 都是 public的
實(shí)現(xiàn)接口必須是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
總結(jié)
- 上一篇: java题库10
- 下一篇: Java虚拟机的体系结构