High Frequency Interview Questions and Answers

Data Structure

  1. Advantage and disadvantage of Adjacency list and Adjacency Matrix
    https://www.geeksforgeeks.org/graph-and-its-representations/
    Adjacency list
    Pros: Saves space O(|V|+|E|) . In the worst case, there can be C(V, 2) number of edges in a graph thus consuming O(V^2) space. Adding a vertex is easier.
    Cons: Queries like whether there is an edge from vertex u to vertex v are not efficient and can be done O(V).

    Adjacency Matrix
    Pros: Representation is easier to implement and follow. Removing an edge takes O(1) time. Queries like whether there is an edge from vertex ‘u’ to vertex ‘v’ are efficient and can be done O(1).
    Cons: Consumes more space O(V^2). Even if the graph is sparse(contains less number of edges), it consumes the same space. Adding a vertex is O(V^2) time.

  2. Array, ArrayList 和 LinkedList的区别。
    https://www.geeksforgeeks.org/array-vs-arraylist-in-java/
    https://www.geeksforgeeks.org/arraylist-vs-linkedlist-java/

  3. HashMap和TreeMap有什么区别?分别怎么实现的,什么情况下用哪个
    https://www.geeksforgeeks.org/hashmap-treemap-java/

  4. 数据结构Stack和Heap的区别。
    Stack is a linear data structure, also known as LIFO(last in first out) while Heap is a non linear data structure. It is like an upside down tree in which root node is at the top.

  5. graph和tree的差别
    http://freefeast.info/difference-between/difference-between-trees-and-graphs-trees-vs-graphs/

  6. bfs和dfs的差别。
    https://www.geeksforgeeks.org/bfs-vs-dfs-binary-tree/
    https://www.geeksforgeeks.org/breadth-first-search-or-bfs-for-a-graph/

  7. quick sort和heap sort有什么区别?
    https://stackoverflow.com/questions/2467751/quicksort-vs-heapsort
    八大排序算法:https://blog.csdn.net/hguisu/article/details/7776068

  8. 比较排序和非比较排序 特点
    https://stackoverflow.com/questions/25788781/definition-of-non-comparison-sort

  9. BT/BST, vector/arraylist

  10. Set和Map什么区别,
    http://www.java67.com/2013/01/difference-between-set-list-and-map-in-java.html

  11. equals()/hashCode()

  12. Comparable/Comparator

Java Knowledge

  1. Inheritance和composition什么区别? https://stackoverflow.com/questions/2399544/difference-between-inheritance-and-composition
  2. 内存类型:Stack和Heap的区别。
    https://practice.geeksforgeeks.org/problems/stack-and-heap
    整个程序放在heap里,final变量也放在堆里面,函数参数放在stack里面。

  3. pass by ref or pass by val? 简单给了道题来验证
    https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value

  4. 为什么list<Integer>可以,list<int>不行,答要object,不能是primitive,之后不停问java为什么这么设计
    https://stackoverflow.com/questions/14349011/why-i-cant-have-int-in-the-type-of-arraylist
    https://stackoverflow.com/questions/18021218/create-a-list-of-primitive-int/18021276

  5. Thread Pool
    https://www.geeksforgeeks.org/thread-pools-java/

  6. modifier的相同点和不同点 public private protected
    https://www.geeksforgeeks.org/access-modifiers-java/
    https://stackoverflow.com/questions/215497/in-java-difference-between-package-private-public-protected-and-private/33627846
    A private member is only accessible within the same class as it is declared.
    A member with no access modifier is only accessible within classes in the same package.
    A protected member is accessible within all classes in the same package and within subclasses in other packages.
    A public member is accessible to all classes (unless it resides in a module that does not export the package it is declared in).

  7. Java vs c++
    https://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B

  8. Abstract Class and Interface
    https://www.geeksforgeeks.org/difference-between-abstract-class-and-interface-in-java/

  9. Implements vs extends
    https://stackoverflow.com/questions/10839131/implements-vs-extends-when-to-use-whats-the-difference

  10. Singleton Design Pattern
    https://www.geeksforgeeks.org/singleton-design-pattern/

  11. Singleton Class
    https://www.geeksforgeeks.org/singleton-class-java/

  12. Synchronized
    https://www.geeksforgeeks.org/synchronized-in-java/
    A synchronized block in Java is synchronized on some object. All synchronized blocks synchronized on the same object can only have one thread executing inside them at a time. All other threads attempting to enter the synchronized block are blocked until the thread inside the synchronized block exits the block.
    We do not always have to synchronize a whole method. Sometimes it is preferable to synchronize only part of a method. Java synchronized blocks inside methods makes this possible.
    将所有public方法都加上synchronized. 相当于设置了一把全局锁,所有操作都需要先获取锁,java.util.HashTable就是这么做的,性能很低。

OS Knowledge

  1. 线程和进程的区别
    https://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-thread

Web Knowledge

  1. 输入google.com发生了什么 http://edusagar.com/articles/view/70/What-happens-when-you-type-a-URL-in-browser
  2. http和https
    https://www.instantssl.com/ssl-certificate-products/https.html
  3. HTTP Requets https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html
  4. TCP 3-Way Handshake Process
    https://www.geeksforgeeks.org/computer-network-tcp-3-way-handshake-process/

Operating System

  1. Remote Procedure call (RPC)
    https://www.geeksforgeeks.org/operating-system-remote-procedure-call-rpc/

results matching ""

    No results matching ""