2021秋招英文面经
2021-09-25 17:22:41
  1. Hashcode() vs Equals()
1
2
3
4
5
6
7
​​Java equals() and hashCode() methods are present in Object class. So every java class gets the default implementation of equals() and hashCode().

equals() : This method checks if some other object passed to it as an argument is equal to the object in which this method is invoked. For the original Object.equals function, it returns true if o1 is the same object as o2, otherwise return false.

hashCode(): This method returns a hashCode() value as an Integer and is supported for the benefit of hashing based Collection classes like Hashtable, HashMap, HashSet etc. If a class overrides the equals() method, it must implement the hashCode() method as well.

In conclusion, if o1.equals(o2), o1.hashCode() == o2.hashCode(). But if o1.hashCode() == o2.hashCode(), o1.equals(o2) may return false.
  1. Override vs Overwrite (存疑)
1
2
3
4
5
6
7
8
In Java, there is no overwrite keyboard, or we can say override is the same conception as overrwrite. Therefore, this is a question for C++.

For override, it means making a method with virtual keyboard in the base class and the base class allows to the child classes to make a body of same
method for itself.

Overwrite means override without virtual keyboard.

There is another keyboard which is overload. It means making multiple methods with different input parameters.
  1. How to make code scalable?
1
2
3
4
5
6
7
From the aspect of code, it should be humongous. 

First of all, it should be clear. To make a modification in the code, one has to first understand what is currently doing. So it's quite important that "the code should be easy to understand". There are some methods. For example, using single responsibility pinciple, breaking long methods into single function or simpler methods.

Secondly, design detailedly before programming. It means "one should not have to rewrite/refactor the old code to add a new feature". It increases the scope of testing because we need to test the functionality of the old code as we modified it.

Lastly, the code should be efficient. It means one should be able to make the changes without any effort or without writing a duplicate code anywhere. If a piece of code is written somewhere, one should be able to re-use it instead of copying.
  1. Testing tactics you often use in your daily work

Black-box testing and white-box testing.
Black-box testing is also known as

  1. Garbage collection vs tradition memory management
  2. Memory leak
  3. CPU keep rising but ram maintain the same?
  4. How to fix slow tests suite -
    • Identify flaky test
    • Break the tests suite into several categories
    • Mock response/testing data if needed. Reduce the external dependency when it comes to
      Testing
    • Create more unit tests instead of integration test. Reuse dataset for integration test
  5. Difference between inheritance vs composition
  6. How do you speed up release cycle - Continuous deploymen
  7. Dependency injection
  8. What needs to be paying attention to when adding a new class into collection framework
  9. What is race condition vs deadlock?
  10. Given a function, when you keep divide by 10 to find out how many digits it has, what’s the time complexity of it? - log
  11. When does O(nlogm) is faster than O(n+m) - it depends on the the value of m, if m is huge, then obviously the first one is better. Otherwise the second one.
  12. How to handle thread pool exhaustion - Thread exhaustion happens when you create too many threads to handle requests, which eventually cause taking up too many
    Resources.
  13. How to test web service QPS when it scale up?
  14. Convert text to bytes and find the sentences between two new lines? What would be the problem?
  15. Under what circumstance you should not use java garbage collection?
  16. What are some pros and cons for predefined testing?
  17. How do you select dataset for testing?
  18. How do you test a shortest path?
  19. How to scale up a service from 1 tps to 1000 tps? Broad questions -
    1. Codewise - Find bottleneck and fix it.
    2. Hardware wise
  20. There are 200 servers with distributed system. There are some random system that would be down during a specific time. Why?
  21. What is same origin policy? How to overcome?
  22. The graph is showing you fluctuate 500 errors - Why is that?
  23. The graph is showing you fluctuate latency time - Why is that
  24. What is the most important object oriented programming principle for complex system? - Separation of concerns - Make everything one module and start from there
  25. Choose the most appropriate data structure for each problem type:
  • A hierarchical file system model = …………………………
  • An undo / redo history in an app = …………………………
  • Orders to be processed in-order and sequentially = …………………………
  • Boolean option flags in a memory constrained device = …………………………
  1. What are some potential reasons that the query is slow?
    1
    2
    3
    4
    5
    6
    7
    SELECT *
    FROM Deployment
    WHERE Deployment.ApplicationId =
    (SELECT ApplicationId
    FROM Applications
    WHERE Name = params.AppName)
    AND Deployment.Timestamp < params.SinceTime
  2. Your team ‍‍‍‍‌‍‍‍‍‌‍‌‍‍‌‍‍‍‍is building a RESTful API of the following form, that returns the car history given the VIN number (which is a unique identifier of all registered vehicles).
  3. How would you benchmark the performance and load capacity of this API
    System design:
  4. How to show a Facebook post to this person’s friend
  5. If there are 100 servers running google doc, how do you utilize load balancer - Please talk about load balance strategy.
Prev
2021-09-25 17:22:41
Next