- 相關(guān)推薦
Sun認(rèn)證Java程序員(SCJP)考題常見(jiàn)陷阱集合
(1) Two public classes in the same file. (illegal)
同一個(gè)文件里有兩個(gè)public類(lèi)。(非法)
(2) Main method calling a non-static method. (illegal)
在main(String[] args)方法內(nèi)調(diào)用一個(gè)非靜態(tài)方法。(非法)
(3) Methods with the same name as the constructor(s). (這種題常有)
與Constructor(s)有相同名字的方法。
(4) Thread initiation with classes that do not have a run() method.
初始化了一個(gè)沒(méi)有run()方法的線程類(lèi)。
(5) Local inner classes trying to access non-final vars. (illegal)
內(nèi)部類(lèi)嘗試訪問(wèn)非final變量(非法)
(6) Case statements with values out of permissible range. (byte,int, short,chat)
選擇語(yǔ)句case中,沒(méi)有使用允許的值。如(byte、int、short、char)等
(7) Math class being an option for immutable classes !! (totally wrong!)
Math類(lèi)作為不可改變類(lèi)。(完全錯(cuò)誤)
(8) instanceOf is not same as instanceof.
instanceOf不是instanceof。
(9) Private constructors. (legal)
私有的Constructor。(合法)
(10)An assignment statement which looks like a comparison.
一個(gè)賦值語(yǔ)句看起來(lái)像比較語(yǔ)句。
比如說(shuō)if(a=true),和if(a==true)。對(duì)于這種題眼睛亮一點(diǎn)。
(11)System.exit() in try-catch-finally blocks. (finally不會(huì)執(zhí)行)
在try-catch-final塊中的退出語(yǔ)句。(finally不會(huì)執(zhí)行)
(12)Order of try-catch-finally blocks matters. (若順序錯(cuò)的話: error: No try before catch)
try-catch-final塊的順序問(wèn)題。
(13)main() can be declared final. (OK)
main()方法可以聲明為final。
(14) -0.0 == 0.0 is true.
(15)A class without abstract methods can still be declared abstract.
沒(méi)有抽象方法的類(lèi),仍然可以定義為抽象類(lèi)。
【Sun認(rèn)證Java程序員SCJP考題常見(jiàn)陷阱】相關(guān)文章:
sun認(rèn)證java程序員08-05
sun認(rèn)證java程序員須知Java日志框架09-05
sun認(rèn)證Java枚舉常見(jiàn)7種用法08-13
Sun java認(rèn)證考試答案10-23
SUN JAVA程序員和開(kāi)發(fā)員(SCJD)認(rèn)證07-25