JAVA初始化的陷阱Java认证考试
文章作者 100test 发表时间 2010:01:08 19:10:23
来源 100Test.Com百考试题网
为了说明这个问题先给大家出个问题吧:
请看代码:
view plaincopy to clipboardprint?
public abstract class A {
public A() {
initMethod().
}
public abstract void initMethod().
}
public abstract class A {
public A() {
initMethod().
}
public abstract void initMethod().
}
view plaincopy to clipboardprint?
public class B extends A {
static String staticStr = "static1".
private String testStr = "Test1".
/*
* (non-Javadoc)
*
* @see A#initMethod()
*/
public void initMethod() {
// TODO Auto-generated method stub
testStr = "Test2".
staticStr = "static2".
}