月度归档:2018年04月

近期安排+京东百度面经

最近在忙什么

在3月底的时候,在牛客网看到了春招马上就结束了,之前的计划是春招不参加,抓紧准备秋招.但是看到能投
简历又不甘心这么好的机会就放过去,所以来试了一下.去面试的时候也没有抱有很大的希望,单纯的是去找
刺激的(刺激确实找到了…),但是收获了京东的offer,非常感谢京东能给我这次机会.

投过简历的企业(按照顺序)

  1. 网易
  2. 阿里巴巴(淘宝)
  3. 百度
  4. 京东
  5. 头条

网易:

网易这次笔试我认为难度挺大的(水平不够),编程题没做出来几个,直接笔试就没有过.

阿里巴巴

阿里只有一到相对简单的笔试题,当天下午做过之后,晚上9:30左右1面电话就打来了(周五).问了关于多线程, 集合框架,并发,GC,Spring AOP/IOC相关知识点.每一个知识点从基础的使用,到源码,到JVM,到优化方法.
非常非常的细致,我答的非常不好.

面试官是非常棒的,很有耐心的引导我,可是不会就是不会.最后面试官告诉我 学习一个知识的时候,不能只
从表面理解它.可能百度一下,也能实现需求,但是不能止步于此,应该继续往下查找为什么这样子,它是如何
实现的,有更好的方法没有.
受益匪浅,虽然面试官拒掉了我,但是我还是很开心的.有前辈告诉我如何学习,
真的可以节省很多时间.

同时,可见阿里是一个注重基础的公司, 想要加入阿里,需要有非常扎实的基础知识 .

百度

作为BAT中的老大,虽然近些年发展不如其他企业,但是依然占据着中国互联网的入口,是非常具有吸引力的.
在1面中被刷,没什么不好意思的,知识水平不足.面试官考了一个遍历和翻转二叉树的简单算法,我没有能
写出第二个代码来(纸笔).在面试的过程中,面试官提到了刷题,我是不赞成刷题的,我认为刷题并不能体现出
一个人的知识水准,只能体现出是否预先做过准备,联系过.话虽然这么说,我也是理解面试官的,在这个行业,
除了这么面试,我也实在想不出其他更好的办法了.
总之,百度需要较强的算法基础,你必须进行大量刷题,训练才能够通过面试.不论是否赞成这种做法,
现在面对的情况就是这样子的,如果基本算法都不会,公司凭什么会认为你能进行更复杂的工作.所以说,
只有拿下算法题,才有资格继续讨论其他问题.在暑假可能需要刷题了.

京东

一面

面试官问得问题都是偏向实用的,比如说spring框架的基本使用,java的基础操作和一些概念的区别,主要是集合.
不同面试官性格不同,问题差异可能会较大.面试我的面试官可以看得出也是非常喜欢计算机的,喜欢研究新技术,
问到了我最近关注的前沿技术有什么.
期间问到了一个算法题,剑指offer原题.在大量数字中高效选出最大的/出现次数最多的几个数.算法是弱项,回答
出来的就是暴力而已,没有想到最佳答案.真的需要加强算法了.
面试结束后,面试官主动站起来握手,让我感受到他是非常尊重面试者的,希望以后有机会能在一起工作.我认为,不论
一个人技术水平如何,首先,尊重其他人是最基本的.

二面

二面面试官应该是个大佬,话非常少..问了GC和类加载,然后随便闲聊了几句,就放我出来了.我一度感觉这是要凉了.
但是出门后在官网上查到已经是hr面试未安排,还好放了我一马.

HR面

HR是一个非常热情的阿姨,核心问题就两个,居住和加班.我是租房子的,所以住在哪里这个问题很容易就解决了.加班的话
也是能接受的,晚上管饭也有班车,对于我这样大学实习/刚毕业没什么影响,所以很愉快的就过了.同时和我说了很多JD内部
部门的分化,说的非常详细.

最后一点让我印象深刻的,三面所有面试官,都说我是他们这几天面试中唯一的一个本科生,他们非常惊讶…压力真的非常大啊,现在
本科学历都成了起步学历了,找工作竞争的都是硕士博士,想要在这样的比赛中获胜,或许得付出几倍于他们的努力.

头条

时间冲突,未参加笔试.

最后

希望在秋天有丰富的收获.

2018/5/28-02:21

Basic knowledge of collection framework – 1

Basic Knowledge of Collection Framewrok


Class Hierarchy Of Collection Framework:


Difference about List,Queue,Set,Map interface:

The entire collection framework is divided into four interfaces.

  1. List —> It handles sequential list of objects. ArrayList, Vector and LinkedList classes implement this interface.

  2. Queue —> It handles special list of objects in which elements are removed only from the head. LinkedList and PriorityQueue classes implement this interface.

  3. Set —> It handles list of objects which must contain unique element. This interface is implemented by HashSet and LinkedHashSet classes and extended by SortedSet interface which in turn, is implemented by TreeSet.

  4. Map —> This is the one interface in Collection Framework which is not inherited from Collection interface. It handles group of objects as Key/Value pairs. It is implemented by HashMap and HashTable classes and extended by SortedMap interface which in turn is implemented by TreeMap.

Three of the above interfaces (List, Queue, and Set) inherit from the Collection interface. Although Map is included in the collection framework it does not inherit from the Collection interface.


Collection interface method

The collection interface contains total 15 abstract methods. 14 of it’s own and one is inherited from Iterable interface. Here is the list and descriptions of those methods.

equals() and hashcode() methods in the Collection interface are not the methods of java.lang.Object class. Because, interfaces does not inherit from Object class. Only classes in java are sub classes of Object class. Any classes implementing Collection interface must provide their own version of equals() and hashcode() methods or they can retain default version inherited from Object class.


original:

Basic knowledge of collection framework – 2

Advantage of using ArrayList over Arrays

Drawbacks of Arrays:

  1. Arrays are fixed length, once created, you can not change the size of the array.
  2. After Arrays are created , you can not accommodate an extra element.
  3. Memory is allocated to an array during it’s creation only, much before the actual elements are added to it.

Advantages of ArrayList:

  1. You can define ArrayList as re-sizable array. Size of the ArrayList is not fixed. ArrayList can grow and shrink dynamically.
    class ArrayListDemo{    public static void main(String[] args)    {        ArrayList<String> list = new ArrayList<String>();         list.add("ONE");         list.add("TWO");         list.add("THREE");         System.out.println(list.size());     //Output : 3         //Inserting some more elements        list.add("FOUR");         list.add("FIVE");         System.out.println(list.size());    //Output : 5         //Removing an element        list.remove("TWO");         System.out.println(list.size());    //Output : 4    }}
  2. Elements can be inserted at or deleted from a particular position.
    class ArrayListDemo{    public static void main(String[] args)    {        ArrayList<String> list = new ArrayList<String>();         list.add("ZERO");         list.add("TWO");         list.add("FOUR");         System.out.println(list);     //Output : [ZERO, TWO, FOUR]         list.add(2, "THREE");       //Inserting an element at index 2         list.add(1, "ONE");     //Inserting an element at index 1         System.out.println(list);    //Output : [ZERO, ONE, TWO, THREE, FOUR]         list.remove(3);       //Removing an element from index 3         System.out.println(list);    //Output : [ZERO, ONE, TWO, FOUR]    }}
  3. ArrayList class has many methods to manipulate the stored objects.

ArrayList class has methods to perform solo modifications ( add(), remove()… ), bulk modifications ( addAll(), removeAll(), retainAll()… ), searching( indexOf(), lasIndexOf() ) and iterations( iterator() ).

  1. If generics are not used, ArrayList can hold any type of objects.

    class ArrayListDemo{    public static void main(String[] args)    {        ArrayList list = new ArrayList();     //ArrayList without generics         list.add("ZERO");    //adding string type object         list.add(1);        //adding primitive int type         list.add(20.24);    //adding primitive double type         list.add(new Float(23.56));   //Adding Float wrapper type object         list.add(new Long(25));      //Adding Long wrapper type object         System.out.println(list);     //Output : [ZERO, 1, 20.24, 23.56, 25]    }}
    1. Many are of the assumption that multiple insertion and removal operations on ArrayList will decrease the performance of an application. But, there will be no significant change in the performance of an application if you use ArrayList instead of arrays. Below example shows time taken to add 1000 string elements to ArrayList and array.
      class ArrayListDemo{    public static void main(String[] args)    {        String[] namesArray = new String[1000];         long startTime = System.currentTimeMillis();         for (int i = 0; i < namesArray.length; i++)        {            namesArray[i] = "Name"+i;        }         long endTime = System.currentTimeMillis();                   System.out.println("Time taken by Array : "+(endTime - startTime)+"ms");         ArrayList<String> nameList = new ArrayList<String>();              startTime = System.currentTimeMillis();         for (int i = 0; i <= 1000; i++)        {            nameList.add("Name"+i);        }         endTime = System.currentTimeMillis();         System.out.println("Time taken by ArrayList : "+(endTime-startTime)+"ms");    }}

      Output :
      Time taken by Array : 6ms
      Time taken by ArrayList : 6ms

  2. You can traverse an ArrayList in both the directions – forward and backward using ListIterator.

    class ArrayListDemo{    public static void main(String[] args)    {            ArrayList<String> list = new ArrayList<String>();                 list.add("ONE");                 list.add("TWO");                 list.add("THREE");                 list.add("FOUR");                 ListIterator iterator = list.listIterator();                 System.out.println("Elements in forward direction");                 while (iterator.hasNext())        {            System.out.println(iterator.next());        }                 System.out.println("Elements in backward direction");                 while (iterator.hasPrevious())        {            System.out.println(iterator.previous());        }    }}
  3. ArrayList can hold multiple null elements.

    class ArrayListDemo{    public static void main(String[] args)    {        ArrayList<Integer> list = new ArrayList<Integer>();              list.add(100);         list.add(null);         list.add(null);         System.out.println(list);     //Output : [100, null, null]    }}
  4. ArrayList can hold duplicate elements.

    class ArrayListDemo{    public static void main(String[] args)    {        ArrayList<Integer> list = new ArrayList<Integer>();              list.add(100);         list.add(100);         list.add(100);         System.out.println(list);     //Output : [100, 100, 100]    }}

(Above two advantages(7 and 8) are also applicable to arrays. But, you can treat them as bonus with all above advantages of ArrayList.)

orginal link