还有这个问题:
What will happen when you attempt to compile and run the following code?. class Background implements Runnable{
int i=0;
public int run(){
while(true){
i++;
System.out.println("i="+i);
} //End while
return 1;
}//End run}//End class
1) It will compile and the run method will print out the increasing value of i.
2) It will compile and calling start will print out the increasing value of i.
3) The code will cause an error at compile time.
4) Compilation will cause an error because while cannot take a parameter of true. 给出理由,顺便测试一下您对java基础的掌握知识
What will happen when you attempt to compile and run the following code?. class Background implements Runnable{
int i=0;
public int run(){
while(true){
i++;
System.out.println("i="+i);
} //End while
return 1;
}//End run}//End class
1) It will compile and the run method will print out the increasing value of i.
2) It will compile and calling start will print out the increasing value of i.
3) The code will cause an error at compile time.
4) Compilation will cause an error because while cannot take a parameter of true. 给出理由,顺便测试一下您对java基础的掌握知识
http://java.sun.com/docs/books/tutorial/java/javaOO/override.html
参考一下,give me a correct answer!thanks楼上的兄弟好象不感肯定啊!
:-]
File file = null;
//下面两个方法名一样,称为过载,这种构造函数过载是为了我们传参数的随意性,方便
public FileInputStream(File file){
this.file = file;
}
public FileInputStream(String filePath){
file= new File(filePath);
}
}
重申一下,第一个问题的答案是:1,4。
The error is caused because run should have a void not an int return type.