Java 開發工程師面試題

項目背景

Risk Identification 項目。數據庫使用 PostgreSQL,前端使用 React、Ant Design,後端使用 Spring Boot、Spring Cloud、Spring Data,另外還涉及 Jenkins、Kubernetes 等。因爲項目有國外同事,所以需要會英語。(技能要求:Java, Spring Boot, API, JavaScript)

綫上面試

開場白

您好!我是面试官 XXX。

方便开一下摄像头吗?

語言水平

請您用英文做一段簡單的自我介紹。

Okay, thank you for your introduce.

Now, i will ask you some questions. You can try to answer me in English. Are you okay?

Do you have any English certification?

What was the biggest challenge in your last job?

Are you confident in using English in your daily work?

项目经验

請詳細説一下最近做的項目。

Java

Q1. String, StringBuilder, StringBuffer 之间有什么区别?
Factor String StringBuilder StringBuffer
Storage Area Constant String Pool Heap Area Heap Area
Mutability Immutable Mutable Mutable
Thread Safety Yes No Yes
Performance Fast More efficient Less efficient
Q2. Array 和 ArrayList 有什么区别?
Array ArrayList
Cannot contain values of different data types Can contain values of different data types
Size must be defined at the time of declaration Size can be dynamically changed
Need to specify the index in order to add data No need to specify the index
Arrays are not type parameterized Arraylists are type
Arrays can contain primitive data types as well as objects Arraylists can contain only objects, no primitive data types are allowed

Spring

Q1. 项目中常用的注解有哪些?
  • @Controller – for controller classes in Spring MVC project.
  • @RequestMapping – for configuring URI mapping in controller handler methods. This is a very important annotation, so you should go through Spring MVC RequestMapping Annotation Examples
  • @ResponseBody – for sending Object as response, usually for sending XML or JSON data as response.
  • @PathVariable – for mapping dynamic values from the URI to handler method arguments.
  • @Autowired – for autowiring dependencies in spring beans.
  • @Qualifier – with @Autowired annotation to avoid confusion when multiple instances of bean type is present.
  • @Service – for service classes.
  • @Scope – for configuring the scope of the spring bean.
  • @Configuration, @ComponentScan and @Bean – for java based configurations.
  • @Aspect, @Before, @After, @Around, @Pointcut - AspectJ annotations for configuring aspects and advices.
Q2. @RequestMapping 和 @RestController 注解用什么用?
  • @RequestMapping: This provides the routing information and informs Spring that any HTTP request matching the URL must be mapped to the respective method.
  • @RestController: This is applied to a class to mark it as a request handler thereby creating RESTful web services using Spring MVC. This annotation adds the @ResponseBody and @Controller annotation to the class.
Q2. @Autowried 有哪几种注入方式

构造函数注入、属性注入、Setter注入

Q3. @Transactional 什么情况下会失效?

7种情况:非 public 修饰的方法、同个类中调用、异常被捕获、回滚异常类型不对、事务传播特性设置错误、数据库引擎不支持事务、项目没有开启事务

Q4. 如何返回统一的 JSON 数据格式?

在类上注解 @ControllerAdvice,并实现 ResponseBodyAdvice 接口,重写 supports 和 beforeBodyWrite 方法

Q5. 如何统一处理异常?

在类上注解 @ControllerAdvice,在方法上注解 @ExceptionHandler(value = Exception.class)

持久层框架

Q1. 项目中使用了什麽持久層的框架?

Hibernate、Spring Data、MyBatis

Q2. 使用 MyBatis 时,在 XML 文件中,如何实现动态 SQL 查询?会用到什么元素?

if、choose (when, otherwise)、trim (where, set)、foreach

Q3. 使用 Spring Data JPA 时,查询特定字段的接口方法要怎么写?使用使用了什么注解?

@Query、@Query(nativeQuery=true)

数据库

Q1. 数据库慢查询如何分析 SQL?

Explain

Q2. 索引失效的情况?
Q3. TRUNCATE TABLE 与 DELETE TABLE 有什么区别呢?

单元测试

请问有沒有用過單元測試?

请问如何查看項目的單元測試覆蓋率呢?

如何测试某个接口的返回值是否符合预期?
Mock、TestRestTemplate

断言方法有哪些?
assertAll、assertEquals、assertNotNull、assertThrows、assertTimeout、assertTimeoutPreemptively、assertTrue

单元测试与开发进度,哪个更重要呢?

前端框架(全棧時,需考察)

项目中使用了什么前端框架(Vue.js、React)?

谈谈您对 XX 的生命周期的理解?

组件间是如何进行通讯的呢?
prop

Vue.js 的核心是?
声明式渲染,采用简洁的模板语法来声明式地将数据渲染进 DOM 的系统

在 Vue.js 中,如何构建一个局部可用的组件?
通过一个普通的 JavaScript 对象来定义组件,然后在实例的 components 选项中定义你想要使用的组件

在 React 中,如何创建一个有状态的组件?用到了什么方法?
extend React.Component、this.props、this.setState()、ReactDOM.render()

项目协作

使用了什么版本控制系统?
SVN、Git

使用了怎樣的 Git 工作流程?
Git flow、GitHub flow、GitLab flow

使用了什么项目管理软件?
Jira、Redmine、TAPD、Worktile、禪道

使用了什么监控报警工具?

有沒有聽過敏捷開發?对它的理解?

结束语

您还有什么补充或疑问吗?

感谢您来参加今天的面试。

posted @ 2021-05-14 17:32  超懶的薯仔  阅读(54)  评论(0编辑  收藏  举报