1、除类型外,请列举至少5个Java语言的关键字
2、简述Exception、Error的区别
3、简述序列化与反序列化的区别
4、在进行大量字符串拼接,不考虑线程安全问题,String、StringBuilder、StringBuffer性能哪个更高
5、在需要频繁使用List的新增功能时,ArrayList、LinkedList的性能谁更高
6、下列程序的运行结果为
public class Hello {
public int hello = 1;
}
public class Test {
public static void main(String[] args) {
Hello h1 = new Hello();
int h2 = 1;
String h3 = "1";
Change(h1,h2,h3);
System.out.println(h1.hello); //2
System.out.println(h2); //1
System.out.println(h3); //1
}
public static void Change(Hello ch1,int ch2,String ch3){
ch1.hello = 2;
ch2 = 2;
ch3 = "2";
}
}
7、下列程序的运行结果
String str1 = "hello";
String str2 = "hel" +"lo";
String str3 = "hel" + new String("lo");
System.out.println(str1==str2); //true
System.out.println(str1.equals(str2)); //true
System.out.println(str2==str3); //false
System.out.println(str2.equals(str3)); //true
8、下列程序的运行结果
int i =0;
if((i+1) == 1 || (++i) >1){
System.out.println(i); //0
}
if((i+1)==1|(++i)>1){
System.out.println(i); //1
}
9、下列程序的运行结果
public class Hello {
public int hello = 1;
public Hello(int h){
hello = h;
}
}
Hello[] hellos = {new Hello(1),new Hello(2),new Hello(3)};
for (Hello hello : hellos) {
hello = new Hello(22);
System.out.println(hello.hello); //22 22 22
}
System.out.println(hellos[0].hello); //1