a1310747
V2EX  ›  Java

记 Java 面试的时候被问的最多的问题

  •  4
     
  •   a1310747 · Mar 2, 2017 · 10552 views
    This topic created in 3540 days ago, the information mentioned may be changed or developed.
    1.jvm,gc 巴拉巴拉
    2.spring 巴拉巴拉
    3.分布式巴拉巴拉
    4.线程巴拉巴拉
    5.sql 巴拉巴拉
    Supplement 1  ·  Mar 2, 2017
    补充下同事去阿里面试的笔试题。
    1 、 编程写一个函数来实现单链表反转,不能使用第三方类库和函数
    2 、 编程实现策略模式,并说明策略模式和模板模式的区别
    3 、 采用你熟悉的单元测试框架如 junit/testng 写一个测试案例(具体案例忘了),要求尽可能能覆盖多个场景和纬度
    4 、 说明 private/protect/public 访问修饰符的作用范围,并写函数读取一个对象的 private 变量
    5 、 采用你熟悉的 MVC 框架,如 struts/springMVC/servlet 等,编程写出上传一个小文件并返回文件的大小、格式等信息,要求完整写出前端布局及 action 处理,可以直接采用 servlet
    6 、 编程写出一个银行转账案例,如 A 账号向 B 账户转账,尽可能包含转账账户、转账金额、接收账号、银行流水号、汇率等信息,要求考虑百万以上并发,保证事务的流畅性和安全性
    34 replies  •  2017-03-15 11:23:39 +08:00
    Finest
    Finest
    Mar 2, 2017
    1
    补充:
    nio
    hashmap 等 container
    concurrency 包
    clearbug
    clearbug
    Mar 2, 2017 via Android
    2
    具体点的呢
    saharabear
    saharabear
    Mar 2, 2017
    3
    java 和 javascript 的区别。
    gdsagdada
    gdsagdada
    Mar 2, 2017❤️2
    4
    工资期望多少?期望 xxxxx !好吧回去等通知吧。
    AlisaDestiny
    AlisaDestiny
    Mar 2, 2017
    5
    "你都会什么?"
    “我什么都不会!!!!但是,我长得漂亮。”
    “明天来上班。”
    shawshi
    shawshi
    Mar 2, 2017
    6
    1.hashmap 的实现
    wohenyingyu02
    wohenyingyu02
    Mar 2, 2017 via iPhone
    7
    我只问 integer 和 integer 是否相等, int 和 integer 是否相等, int 和 int 是否相等,至今无人答全对,但是还敢要 10k 工资。
    NamekMaster
    NamekMaster
    Mar 2, 2017
    8
    还问分布式么..一定是大神,我去面试只会问 abstract 和 interface 啥区别= =
    henneko
    henneko
    Mar 2, 2017 via Android
    9
    有女朋友没?
    linbiaye
    linbiaye
    Mar 2, 2017
    10
    能加班不
    lonenol
    lonenol
    Mar 2, 2017
    11
    男的直接拒
    thisnull
    thisnull
    Mar 2, 2017
    12
    不填三围拒绝.

    什么? 男的 还填三围的. 拒绝!!!
    obabull
    obabull
    Mar 2, 2017
    13
    @saharabear 周杰和周杰伦的区别,雷锋和雷峰塔的区别,老婆和老婆饼的区别.
    zgqq
    zgqq
    Mar 2, 2017 via Android
    14
    @NamekMaster 装逼的比较多
    akira
    akira
    Mar 2, 2017❤️1
    15
    @AlisaDestiny 这样是不是更符合场景。

    "你都会什么?"
    “我什么都不会!!!!但是,我单身。”
    “明天来上班。”
    nec
    nec
    Mar 2, 2017❤️1
    16
    @wohenyingyu02

    我大概明白你的考察点,但是你的表述不是很清楚。

    关于 int 和 Integer 经典的题目是:

    ```java
    class Test {
    public static void main(String[] args) {
    Integer a = new Integer(3);
    Integer b = 3; // 将 3 自动装箱成 Integer 类型
    int c = 3;
    System.out.println(a == b); // false 两个引用没有引用同一对象
    System.out.println(a == c); // true a 自动拆箱成 int 类型再和 c 比较

    Integer f1 = 100, f2 = 100, f3 = 150, f4 = 150;
    System.out.println(f1 == f2); //true
    System.out.println(f3 == f4); //false
    }
    }
    ```

    补充一下,任何面试都要考察三大基础吧:数据结构与算法+网络+操作系统
    tedzhou1221
    tedzhou1221
    Mar 2, 2017 via iPhone
    17
    你能写出几种单例模式?
    dallaslu
    dallaslu
    Mar 2, 2017
    18
    HashMap 和 HashTable 的区别……
    Cbdy
    Cbdy
    Mar 2, 2017 via Android
    19
    如果我面的话我会问问看过那些书,即使提的问题答不上来,说说思路,靠谱的话也 ok 。

    对了, Java 的话一般还会问问对面向对象的看法。
    a1310747
    a1310747
    OP
    Mar 2, 2017
    20
    @clearbug 补充有阿里的一些笔试题
    a1310747
    a1310747
    OP
    Mar 2, 2017
    21
    @hand515 对...
    a1310747
    a1310747
    OP
    Mar 2, 2017
    22
    @shawshi 的确 这个也是问的比较多的
    a1310747
    a1310747
    OP
    Mar 2, 2017
    23
    @NamekMaster 并不是....分布式我也只用了 zookeeper+dubbo 不过面试官会往深了问 比如: dubbo 的实现原理、内部层次结构等,是否读过 dubbo 源码, zookeeper 的实现原理,如何做到事务的注册和订阅, dubbo 与 zookeeper 如何结合,是否读过 zookeeper 源码等等
    a1310747
    a1310747
    OP
    Mar 2, 2017
    24
    @henneko 有了
    Ouyangan
    Ouyangan
    Mar 2, 2017
    25
    @Cbdy #19 这个问题最考验功力了, 缺乏工程经验看编程思想导论部分看的会非常难受..
    Tneciv
    Tneciv
    Mar 2, 2017 via Android❤️1
    26
    我被问过如何用 3 种方法安装 MySQL
    xiaowangge
    xiaowangge
    Mar 3, 2017 via iPhone
    27
    @wohenyingyu02 核心知识点

    1 、== 和 equals 方法的区别

    2 、 Java caches Integer objects instances from the range -128 to 127. The reasoning is explained here: https://blogs.oracle.com/darcy/entry/boxing_and_caches_integer_valueof
    Lonely
    Lonely
    Mar 3, 2017
    28
    @wohenyingyu02 你问得模糊还说没人全对
    wohenyingyu02
    wohenyingyu02
    Mar 3, 2017
    29
    @Lonely 一共 6 道判断题,你连题都没看就说模糊?
    public class test {
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here
    Integer a=2;
    Integer b=2;
    System.out.println("1. " + (a==b));

    Integer c=1000;
    Integer d=1000;
    System.out.println("2. " + (c==d));

    int e=1000;
    int f=1000;
    System.out.println("3. " + (e==f));

    Integer g = 50;
    int h = 50;
    System.out.println("4. " + (g==h));

    Integer i = 500;
    int j = 500;
    System.out.println("5. " + (i==j));

    Integer k = new Integer(1);
    Integer l = new Integer(1);
    System.out.println("6. " + (k==l));
    }

    }


    @nec
    @xiaowangge

    要是来的人都和 V2EX 一样厉害估计我都失业了哈哈
    GavinHao
    GavinHao
    Mar 3, 2017 via iPhone
    30
    true false true true false false 应该是吧?嘿嘿嘿 我是彩笔
    jhdxr
    jhdxr
    Mar 3, 2017
    31
    @GavinHao 第五个应该是 true 吧, i 会自动拆包然后再和 j 比较的
    thekll
    thekll
    Mar 3, 2017 via iPhone
    32
    通过反射访问 private 变量从业务或者应用角度来看有什么必要性?毕竟这种方式破坏了 private 的封装性。
    a1310747
    a1310747
    OP
    Mar 3, 2017
    33
    @wohenyingyu02
    我对这块也才了解...刚刚去做了 11 个题目 错了三 - -
    Integer a = 1;
    Integer b = 1;
    Integer c = 2;
    Integer d = 3;
    Integer e = new Integer(3);
    Integer e1 = new Integer(3);
    Long f = 3L;
    Long f1 = new Long(3);

    int a1 = 1;
    int c1 = 2;

    System.out.println("1== Integer(1) ?: " + (new Integer(1) == 1));
    System.out.println("a==a1 ?:" + (a==a1));
    System.out.println("a==b ?:" + (a==b));
    System.out.println("d==e ?:" + (d==e));
    System.out.println("e1==e ?:" + (e1==e));
    System.out.println("a + c == d ?:" + (a + c == d));
    System.out.println("a + c == e ?:" + (a + c == e));
    System.out.println("a + c == f ?:" + (a + c == f));
    System.out.println("a1 + c1== f ?:" + (a1 + c1 == f));
    System.out.println("a1 + c1== f1 ?:" + (a1 + c1 == f1));
    System.out.println("a + c equals f ?:" + f.equals(a+c));
    log4geek
    log4geek
    Mar 15, 2017
    34
    我这边也收藏了不少面试题,分享给大伙
    http://log4geek.cc/category/程序员求职 /
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1397 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 76ms · UTC 16:52 · PVG 00:52 · LAX 08:52 · JFK 11:52
    ♥ Do have faith in what you're doing.