My name is Nick. I was born in 1994. I came from Yuncheng, a city in Shanxi province. I went to Kunming science and technology university in September 2012 and graduated in July, 2016.I
    Majored in computer science and technology. I was pretty good at learning during university and my GPA ranked before TOP 10%.
    My second company is Shanghai Shagjia logistic company. I worked as an advanced tech developer.
    I spent lots of time in a project called Hema College, a training app to educate employees. It was an HTML app embedded in an Android app called Dingding, a social software. I was in charge of backed-end development. The tech stacks are java, spring boot, MySQL, Redis, and MQ. This system needed to communicate with other domains. We mainly use Dubbo, an RPC framework to interact.
    That’s all, thanks.

    My name is Nick. I was born in 1994. I came from Yuncheng, a city in Shanxi province. I went to Kunming science and technology university in September 2012 and graduated in July, 2016.I
    Majored in computer science and technology. I was pretty good at learning during university and my GPA ranked before TOP 10%.
    After graduated from university, I was hired by Shanghai Hand Tech company as a tech consultant.
    I mainly used java, MySQL, Redis, etc, those techs to finish my daily work. The first project I took part in is called Supply Chain. I used PL/SQL, an oracle coding language, to develop the program. During that project, I learned how to cope with bugs and how a big industrial software works.
    The second project I participated in was called financial and business integration. We used java as the coding language, SSM as web framework, Redis as cache, MySQL as database. I was in charge of a single module called the accounting engine. I worked hard to solve problems, such as reduce the system response time by optimizing an algorithm.
    My second company was Shanghai Shagjia logistic company. I worked as an advanced tech developer.
    I spent lots of time in a project called Hema College, a training app to educate employees. It was an HTML app embedded in an Android app called Dingding, a social software. I was in charge of backed-end development. The tech stacks are java, spring boot, MySQL, Redis, and MQ. This system needed to communicate with other domains. We mainly use Dubbo, an RPC framework to interact.
    That’s all, thanks.

    Java Enum vs Constants
    1. 枚举:

      1. 枚举是类,相比常量stringint类型,在编译期类型校验比较强 枚举可以用==比较,方便阅读。<br /> 枚举集中管理常量的类型,易于理解和阅读。<br /> 枚举有内置方法,例如values,适合遍历场景。 整体来说,能用枚举尽量用枚举。

    in Compile-time , parameter type verification is relatively strong.
    Enumeration can be compared with double equal sign for easy reading.
    Enumerations centrally manage the types of constants, which are easy to understand and read.
    Enumerations have built-in methods, such as values, which are suitable for traversing scenarios. In general, use enumerations as much as possible.

    1. IO vs NIO

      1. C10K问题,客户端处理1w个连接。 介绍selector epool nginx选择epool模型,优化好可以达到百万/千万级别,例如磁盘写入优化,配置优化。 简单介绍异步io <br />C10K problem, the client handles 10 thousands connections. Introduce selector and epool. Nginx selects the epool model, which can be optimized to reach the million/tens of millions level, such as disk write optimization and configuration optimization. A brief introduction to asynchronous io,

    3

    The difference between class.forName and classLoader

    class.forName 加载JVM,并且初始化static。 classLoader不会初始化static,是一个延迟加载。
    class.forName loads the JVM and initializes static methods. classLoader does not initialize static, it is a lazy loading.
    4

    What are the types of class loaders?
    1. 双亲委派模型:其实就是读取class文件的东西。<br /> Parental delegation model: In fact, it reads the class file.<br /> 关键字: 加载**不同路径**下面的class文件。<br /> key words: loading the class files which are not in the same paths.<br /> bootstrap class loader; <br /> c++编写,加载rt.jar,核心类库<br /> written by C++, loading rt.jar, and core class library.<br /> extension class loader;<br /> 加载ext目录下jar,开发者可以调用<br /> Load the jar in the ext directory, developers can call/invoke.<br /> application class loader;<br /> 加载当前应用下的类。开发默认使用的就是这个类加载器。<br />Load the classes under the current application. Developers use this classloader by default.<br /> 自定义 class loader;<br />5.
    How to clone an Object?
    1. 有个概念是对于引用是复制的引用,并没有复制对象。 所以有对象引用的话,是浅clone。一般都需要深度克隆。 一般我们使用springutilsbean工具类去做。 或者也可以用java的流去做.<br />There is a concept that references are only copied references, and objects are not copied. So if there is an object reference, it is a shallow clone. Generally, deep cloning is required. Generally, we use the bean tool class of springutils to do it. Or you can use java stream to do it.<br />6.
    What is BlockingQueue? How can we implement Producer-Consumer problem using Blocking Queue?

    顾名思义,阻塞,意味着生产和消费的时候可以阻塞调用。 一个线程生产,put入队列。 一个线程消费,take出队列。 java里面的阻塞队列有 ArrayBlockingQueue, linkedblockingqueue,priorityblockingqueue .
    As the name implies, blocking means that the call can be blocked during production and consumption. A thread is produced and put into the queue. A thread consumes and takes out of the queue. The blocking queues in java are ArrayBlockingQueue, linkedblockingqueue, priorityblockingqueue
    7.

    The difference between dynamic and static proxy, what scenarios are used?
    1. 静态代理: 程序运行期提前生产的class文件。 实现方式就是组合,且实现同一接口。相比动态,就是重复代码多<br />Static proxy: class files were produced in advance before running-time. The implemented way is through combination, and implement the same interface. Compared with dynamic, it means more code<br /> 动态代理:程序运行期反射机制生成的代理对象,也是aop的基本原理。<br />Dynamic proxy: The proxy object generated by the reflection mechanism during running-time is also the basic principle of aop.<br />8.
    What is a method reference in Java 8?
    1. :: 左边是类名或者对象,右边是方法名或者new 还有引用数组<br />The left part is class name or object name, the right part is method name(including construction method(new) and reference array)<br />9.
    What is a Lambda Expression and what is it used for?
    1. 以前是匿名函数,匿名对象。 本身是一个接口的实现。<br />It used to be anonymous functions, anonymous objects. It is an implementation of an interface.<br /> 作用: 代码简洁。<br /> looked simple .

    1. | What is Full GC? | | —- |

    Under allocation of JVM heap size or Under allocation of Perm Gen/metaspace。
    老年代空间不足或者是永久代/方法区空间不足,会造成应用卡顿。

    Mention some of the most important VM (JVM) PARAMETERS you have used in JVM Heap memory?

    方法区是定义。 永久代和metaspace是不同版本的叫法。
    method area is definition. permanent and metaspace is just a name in different versions.
    参数: Xmx Xms 定义起始堆大小和最大堆大小。定义newratio比例。
    Define the ratio of new and old.

    11.

    How to detect a Deadlock in Java?

    死锁产生原因: 资源加锁顺序不对。
    Cause of Deadlock: the locking sequence of resources is wrong.
    可以用工具jconsole,jvisual,可以用jstack.
    12

    Is Synchronization an overhead? If yes, How?

    不是,做了很多优化。 锁有三种状态,通过对象头的mark word来标识。
    No, a lot of optimization has been done. The lock has three states, which are identified by the mark word of the object head.

    1. biased 当一个线程使用时。
    2. thin using cas 算法,申请锁的线程采用自旋方式来获取锁。适用于并发不激烈,读多写少场景

    The thread applying for the lock acquires the lock by spinning. It is suitable for the scenario of less intense concurrency and more reading and less writing

    1. fat 依赖系统锁,适用于并发写入多,竞争激烈场景,避免无效的反复尝试等待。

    Spring:

    Blocking v.s. Reactive

    底层servlet的响应是一对一。 200requests/s.
    Spring mvc 是 一对一,同步阻塞io,最差的。
    spring webflux, 异步非阻塞io,适合io密集型的场景,利用多核优势,处理并发链接。 基于异步和事件驱动。 并不能提高系统响应,提高吞吐量。
    webflux 不支持mysql,springmvc容易调试,能用mvc就用mvc。
    应用: 依赖引入,特定的写法。

    2
    Explain spring profiles
    1. 不同环境不同配置。 可以通过启动参数配置,或者javaapi指定。<br />3.
    How to implement security in spring boot?

    using https
    cross-site request forgery: 解决方案: 增加隐藏字段。
    JWT token 验证。
    4.

    Difference between @ConfigurationProperties and @Value.

    @ConfigurationProperties 是map到bean里面。 @value是获取对应key的value.
    5

    Please share Circuit Breaker in SpringCloud.

    防止由于单点故障,引起集群瘫痪。主要是HYstrix,
    手段有
    服务熔断 请求超时
    服务降级
    服务限流:
    限制总并发数(例如线程池大小限制)
    限制窗口期的请求数量
    开发实践: 1. 引入依赖 2. 启动类开始enablecircutbreaker.
    3.使⽤@HystrixCommand注解进⾏熔断控制, 控制方法级别, 原理是aop切面实现,有调用future异步编程。
    dubbo也有服务降级,对外统一返回结果。timeout根据提供者的时常决定。
    retries 参数,要首先注意服务是否幂等,其次注意服务是否有缓存,防止雪崩。
    可以用@reference(mock=return null) 来实现熔断。服务方的。
    dubbo也有负载均衡,服务端和消费端
    看看dubbo的配置代码 和 超时怎么实现的
    dubbo超时针对消费端,因为是nio,获得future,通过future机制实现。
    服务端可以设置超时是给客户端简化配置。,
    Hystrix的超时机制实现?
    2个线程,一个任务线程,一个timer线程。进行CAS判断,不管怎样,都会执行任务线程。是服务端的超时。

    RESTFUL API

    How do you enable Cross Origin Requests for a RESTful Web Service?

    加注解: @crossorigin

    GET 和 POST 区别
    GET方式通过URL提交数据,数据在URL中可以看到;POST方式,数据放置在HTML HEADER内提交。但是,我们现在从RESTful的资源角度来看待问题,HTTP GET方法是幂等的,所以它适合作为查询操作,HTTP POST方法是非幂等的,所以用来表示新增操作。

    How to Design & Manage APIs?
    1. get , post , put, delete 动词+宾语
    2. 设计成 json.
    3. 根据业务模块区分。
    4. 发生错误时,不要返回 200 状态码, 返回400,
    What are the HTTP methods supported by REST?
    1. get post put delete patch
    2. 200, 404,400, 405没有权限

    GET PUT POST DELETE PATCH(部分更新,非幂等)

    What is the difference between PUT and POST http methods?
    What is RAML?

    api设计工具: 包括 apidesigner,apiconsole.

    What are HTTP response codes?

    303 See Other:表示参考另一个 URL。
    400 Bad Request:服务器不理解客户端的请求,未做任何处理。
    403 Forbidden:用户通过了身份验证,但是不具有访问资源所需的权限。
    401 Unauthorized:用户未提供身份验证凭据,或者没有通过身份验证。
    500 Internal Server Error:客户端请求有效,服务器处理时发生了意外。
    429 Too Many Requests:客户端的请求次数超过限额。
    404 Not Found:所请求的资源不存在,或不可用。

    How do you test RESTful web services?

    采用postman测试。

    REST services being stateless, can we make it stateful?

    可以加入cookie,seesionid等参数。
    Engineering

    How to test a class have external dependency? E.g. Database, MQ, Web Services.

    使用 mokito进行模拟。

    Code coverage

    maven集成jococo,生成报告

    How To Perform TDD Test?

    TDD: 先测试(失败),后代码,后测试(成功)。
    优点: 结构更清晰。设计会更好。更快速的反馈,不会到上线才知道出错。
    DDD: 需要懂业务,有业务专家,然后抽象出业务模型。

    When should we use Singleton?
    1. 确保系统中只有一个实体对象。
    2. 节省资源,只需要一个频繁用就很节约。

    场景: 对象需要在公共场合频繁使用,例如线程池,连接池。
    对象创建耗时耗资源

    Factory Method vs Abstract Factory

    单一原则;里氏替换原则;依赖倒置原则;接口隔离;迪米特原则;开闭原则
    类本身就是对象的抽象,但是抽象工厂是对类的抽象,相同方法、相同属性的归并。
    https://alleniverson.gitbooks.io/java-design-patterns/content/Chapter%2004%20Factory%20Method/%E5%B7%A5%E5%8E%82%E4%B8%89%E5%85%84%E5%BC%9F%E4%B9%8B%E5%B7%A5%E5%8E%82%E6%96%B9%E6%B3%95%E6%A8%A1%E5%BC%8F.html
    简单工厂模式将日志对象的实例化推迟到工厂中,实现了应用和日志对象的实例化的解耦
    简单工厂: 违反了开闭原则。要不停修改工厂类
    工厂方法模式: 采用接口设计, 解决了开闭原则。 具体工厂负责一类产品,想增加可以加具体工厂和具体产品。
    抽象出了抽象工厂,是最顶层的抽象,下层有具体工厂。
    抽象工厂 <—具体工厂.
    产品 <—-具体产品。
    例子: spring的factorybean,还有日志框架的slf4j
    抽象工厂模式: 具体工厂负责一族产品,不止一类产品。

    1. 抽象工厂是最顶层抽象。 2. 具体工厂实现一族产品(即多种产品)。

      优势: 适合增加一族产品,这样只需要具体工厂和具体产品的添加。对已有代码不改变
      劣势: 不适合增加一种产品,这样连抽象工厂都需要更改。
      开闭原则倾向性: 适合增加产品族,不适合增加产品等级。 构成一个产品族只需要组合各种产品,但是增加产品则需要修改产品族结构代码。
      使用场景: 产品类型等级结构完整,后期不增加不减少.
      属于同一个产品组的产品将在一起适用。有产品组的约束性。

    What is the advantage of doing scrum?

    快速迭代开发。 需要更好的系统设计,应对后续的变化。

    What is the duration of the scrum sprint?

    冲刺包括冲刺规划冲刺执行冲刺评审冲刺回顾四大过程

    How is agile different from waterfall?
    1. agile 适合大项目 2. agile 缺乏一定初期设计文档和需求,需要边走边看。
    2. 敏捷成本高。
    Activity Diagram

    活动图本质上是一种流程图,它描述活动的序列,即系统从一个活动到另一个活动的控制流
    泳道表明每个活动是由哪些人或哪些部门负责完成

    State Diagram
    Class Diagram

    类直接关系: 继承 实现 关联 组合 聚合 依赖。
    平时画用例图。