java面试题常见的坑_java那些年踩过面试题的坑,你是否依旧记忆犹新!

那些年做过经典的JAVA面试题,看看你是否依旧能够全部做对呢?有时候停下脚步回头瞅瞅也是一件很有意思的事情。答案在最后哦。

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

2题解释:

public void

two(){

int i =

Interger.Max_VALUE;

System.err.println((i+1)

System.out.println("2

存在一个i,使得(i+1)

}

4题解释:

private

static volatile int count = 0;

private

static void four() {

ExecutorService

executorService = Executors.newCachedThreadPool();

for (int j =

0; j < 10; j++) {

executorService.submit(()

-> {

for (int i =

0; i < 1000000; i++) {

count++;

}

});

}

System.out.println("count

should be: " + 10000000 + ", actual be: "+ count);

System.out.println("4.

volatile不能保证线程安全");

}

5题解释:

private

static void five() {

ArrayList

list = new ArrayList<>(20);

list.add(1);

System.out.println("debug

code, not execute grow method");

System.out.println("5.

list grow 0 times");

}

6题解释:

private

static void six() {

System.out.println("BufferedReader's

constructor only accepts a Reader instance");

System.out.println("6.

new BufferedReader(new FileInputStream(\"a.dat\")); is

wrong");

}

a4c26d1e5885305701be709a3d33442f.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值