JAVA题库:格林模拟试题二(下)(1)

文章作者 100test 发表时间 2007:03:14 17:05:42
来源 100Test.Com百考试题网


question 31)

what will happen when you attempt to compile and run the following code

import java.io.*.
class base{
public void amethod()throws filenotfoundexception{}
}

public class excepdemo extends base{
public static void main(string argv[]){
excepdemo e = new excepdemo().
}

public void amethod(){}
protected excepdemo(){
try{
datainputstream din = new datainputstream(system.in).
system.out.println("pausing").
din.readbyte().
system.out.println("continuing").
this.amethod().
}catch(ioexception ioe) {}

}
}

1) compile time error caused by protected constructor
2) compile time error caused by amethod not declaring exception
3) runtime error caused by amethod not declaring exception
4) compile and run with output of "pausing" and "continuing" after a key is hit


question 32)


what will happen when you attempt to compile and run this program

public class outer{
public string name = "outer".
public static void main(string argv[]){
inner i = new inner().
i.showname().
}//end of main
private class inner{
string name =new string("inner").
void showname(){
system.out.println(name).
}
}//end of inner class
}

1) compile and run with output of "outer"
2) compile and run with output of "inner"
3) compile time error because inner is declared as private
4) compile time error because of the line creating the instance of inner



相关文章


对象引用是怎样严重影响垃圾收集器
谈谈Java语言的垃圾收集器
技巧显得:XML带来的好处
为Java加速——JBuilder6可视化开发环境
JAVA题库:格林模拟试题二(下)(1)
JAVA题库:格林模拟试题二(下)(2)
技巧:Java垃圾收集器使用小诀窍
SCJP考试辅导:Java的垃圾收集机制
Apache如日中天,微软奋起直追
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛