一、 写出下面代码的执行结果 (分值 10 分)
public class Foo {
public static void main(String[] args) {
String strValue="ABCDEFG";
strValue.substring(3);
strValue.concat("123");
System.out.println("result=" + strValue);//ABCDEFG
String value = new String ("ABCDEFG");
System.out.println(strValue== value);//false
}
}
二、 写出下面代码的执行结果
public class Foo{ (分值 5 分)
public static void main(String args[]) {
int x = 100;
int y = 200;
if (x = y)//=是赋值运算符。不是比较运算符。 编译失败。
System.out.println("Not equal");
else
System.out.println("Equal");
}
}
三、 写出下面代码的执行结果 (此题需写出分析过程,没有分析过程不得
分,分值 10 分)
import java.io.IOException;
public class ExceptionTest {
public static void main(String args[]) {
try {
new ExceptionTest().methodA(5);
} catch (IOException e) {
System.out.println("caught IOException");
} catch (Exception e) {
System.out.println("caught Exception");
}finally{
System.out.println("no Exception");
}
}