SUN认证 百分网手机站

Sun认证Java程序员SCJP考题常见陷阱

时间:2017-11-28 18:08:52 SUN认证 我要投稿

Sun认证Java程序员(SCJP)考题常见陷阱集合

  (1) Two public classes in the same file. (illegal)

Sun认证Java程序员(SCJP)考题常见陷阱集合

  同一个文件里有两个public类。(非法)

  (2) Main method calling a non-static method. (illegal)

  在main(String[] args)方法内调用一个非静态方法。(非法)

  (3) Methods with the same name as the constructor(s). (这种题常有)

  与Constructor(s)有相同名字的'方法。

  (4) Thread initiation with classes that do not have a run() method.

  初始化了一个没有run()方法的线程类。

  (5) Local inner classes trying to access non-final vars. (illegal)

  内部类尝试访问非final变量(非法)

  (6) Case statements with values out of permissible range. (byte,int, short,chat)

  选择语句case中,没有使用允许的值。如(byte、int、short、char)等

  (7) Math class being an option for immutable classes !! (totally wrong!)

  Math类作为不可改变类。(完全错误)

  (8) instanceOf is not same as instanceof.

  instanceOf不是instanceof。

  (9) Private constructors. (legal)

  私有的Constructor。(合法)

  (10)An assignment statement which looks like a comparison.

  一个赋值语句看起来像比较语句。

  比如说if(a=true),和if(a==true)。对于这种题眼睛亮一点。

  (11)System.exit() in try-catch-finally blocks. (finally不会执行)

  在try-catch-final块中的退出语句。(finally不会执行)

  (12)Order of try-catch-finally blocks matters. (若顺序错的话: error: No try before catch)

  try-catch-final块的顺序问题。

  (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.

  没有抽象方法的类,仍然可以定义为抽象类。

【Sun认证Java程序员(SCJP)考题常见陷阱集合】相关文章:

1.Sun认证之Java程序员(SCJP)技巧

2.Sun认证Java程序员(SCJP)考试科目介绍

3.合格Sun认证Java程序员(SCJP)具备的能力

4.Sun认证Java程序员(SCJP)考试科目

5.Sun认证Java程序员(SCJP)考试

6.SUN认证JAVA程序员简介

7.sun认证java程序员

8.Sun认证Java程序员(SCJP)考试科目的区别