关于SCJP1.4考试的一些需要注意的地方(六)

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

101.方法中throw RuntimeException或error不必在方法中声明

这和throw checked Exception不一样

102.Catch(X x)can catch subclass of X

103.RuntimeException is the immediate superclass of NullPointException

104.rethrow 异常时,方法中也要声明抛出异常。

105.不可以在方法内部定义static变量,static方法不可以被继承

106.Assert抛出的异常Exception in thread “main” java.lang.AssertionError:true

其中true是expression2 的值

107.Catch(Exception e){} try中不抛出异常,仍然可以编译通过

108.两个

break不可以连着,因为有一个

break reach不到,所以compile error

109.Class A{

Void A(){}

} 这不是错误,只是一个普通的方法罢了。

110.Int[] score={3,4,5,} (right)

Int [] aa=new int[3]{1,2,3} (wrong)

111.如果在方法中声明了一个对象,返回的是对该对象的引用,则无法判断该对象是否可以回收

112.Condition compilation is used to allow tested class to run at full speed.

113.the default constructor has the same access as its class

114. do not use assertions to validate arguments to a public method and command-line

Do not use assert expressions that can cause side effect

Do use assertions to check for cases that you know are never even supposed to happen

115.abstract class have constructors and those constructors are always called when a concrete subclass is initiated.

116.An interface has no constructor, because it is not part of an objects inheritance tree.

117.private的构造函数只是不能被继承而已,不会因此compile error

118.boolean b=Boolean.TRUE (wrong)

119.public synchronized void run(){} (right,并且也覆盖run方法)

120.String s=”abc”; Object o=(Object)o;

s.equals(o) =true o.equals(s)=true 因为自动绑定

String s=new String(“true”);

Boolean b=new Boolean(true)

s.equals(b) =false

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航