JAVA笔试题(1)

1、判断对象类型的方法?

     instanceof


2、根据程序写结果 (F:false,T:true)

     public class Main {
    public static void main(String []args){
        String a="str"+"ing";
        String b="str".concat("ing");
        String c=new String("string");
        String d="string";
        String e="str";
        String g="ing";
        String h=e+g;//创建了新对象
        System.out.println("a==b: "+(a==b));//F
        System.out.println("a==c: "+(a==c));//F
        System.out.println("a==d: "+(a==d));//T
        System.out.println("a==h: "+(a==h));//F
        System.out.println("b==c: "+(b==c));//F
        System.out.println("b==d: "+(b==d));//F
        System.out.println("b==h: "+(b==h));//F
        System.out.println("c==d: "+(c==d));//F
        System.out.println("c==h: "+(c==h));//F
        System.out.println("d==h: "+(d==h));//F
    }

}



3、ArrayList与Vector的区别?

1、Vector的方法是同步的,ArrayList不是同步的,后者性能比前者好

2、当元素超过初始大小时,Vector将其容量翻倍,而ArrayList只增加50%的容量。


4、实现StringUtil的isEmpty方法?

 public static boolean isEmpty(CharSequence str) {
 if (str == null || str.length() == 0)
 return true;
 else return false;
 }
链接:https://www.zhihu.com/question/20570393/answer/111686024

5、collection和collections区别?

Collection是一个集合接口。它提供了对集合对象进行基本操作的通用接口方法,其接口在类库中有很多具体的实现。
Collections是一个包装类。它包含有各种有关集合操作的静态多态方法。



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值