Android面试题

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值