如果考类似这种 java 面试题会不会太难而且没意义?

2015-10-28 10:16:37 +08:00
 wohenyingyu01
//
Integer c=2;
Integer d=2;
Integer u=1000;
Integer i=1000;
int o=1000;
int p=1000;
System.out.println(c==d);
System.out.println(u==i);
System.out.println(o==p);

求输出值。
3164 次点击
所在节点    问与答
26 条回复
binnchx
2015-10-28 13:16:55 +08:00
我觉得这题很考察基础啊, 比如
Integer a = 127 这句,通过 javap 打印
2: invokestatic #2 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
这句实际执行的是
Integer a = Integer.valueOf(127);
吧,还考了是否知道 IntegerCache, 看一个人是否会看 jdk 源码查问题,很好的题啊。
Comdex
2015-10-28 13:23:47 +08:00
easy job
nikoukou
2015-10-28 14:17:01 +08:00
考过 ojcp 的表示,自动拆箱自动装箱原理,但是毫无卵用,还是考 leetcode 吧
leavic
2015-10-28 14:39:32 +08:00
这个属于陷阱性的题目,作为考点有点无聊,不过中国人这么多年考试经验了,看到太简单的一定会起疑心,再分析一下估计就找出问题了。
mind3x
2015-10-28 19:03:19 +08:00
JLS 规范:

"If the value p being boxed is true, false, a byte, or a char in the range \u0000 to \u007f, or an int or short number between -128 and 127 (inclusive), then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2."
nicegoing
2015-10-29 08:09:28 +08:00
101 ,这题不难的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/231627

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX