JAVA 开发工程师(L1)招聘试题
姓名: 日期: 开始时间: 完成时间:
第一部分:JAVA 知识
一、 写出下面代码的执行结果 (分值 10 分)
public class Foo {
public static void main(String[] args) {
String strValue = "ABCDEFG";
strValue.substring(3);
strValue.concat("123");
System.out.println(strValue);
String value = new String ("ABCDEFG");
System.out.println(strValue == value);
}
}
二、 写出下面代码的执行结果(分值 5 分)
public class Foo{
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");
}
}
void methodA(int i) throws IOException {
if (i%2 != 0)
throw new IOException("methodA IOException");
}
}
评论0
最新资源