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

时间:2023-03-19 07:11:04 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考题常见陷阱】相关文章:

SUN认证JAVA程序员简介10-25

sun认证java程序员须知Java日志框架03-30

SUN JAVA认证介绍12-18

sun java认证报考指南03-08

sun认证java基础模拟试题03-30

sun认证考试:Java.io的使用01-08

sun认证:java程序设计考试试题03-04

sun认证java关于字符串处理技巧03-29

SUN-Java认证考试题库05-19

Sun国际认证03-13