Java CRUD 接口培训考试题(20 道 · 入门版)
一、C# 转 Java 关键差异(第 1 章)— 2 题
1. 本项目 Java 中用于自动生成 getter/setter 的注解是?
A. `@Data`
B. `@Getter`
C. `@Builder`
D. `@ToString`
2. 本项目 Java 中主键生成方式默认是?
A. 数据库自增
B. UUID
C. 雪花算法
D. 序列
二、项目整体架构(第 2 章)— 1 题
3. 本项目一个完整 CRUD 接口的标准调用链是?
A. Controller → Service → Mapper → DB
B. Controller → Service → Repository → Mapper → DB
C. Controller → Repository → Mapper → DB
D. Controller → Mapper → Service → DB
4. 接收前端请求参数并做参数校验的对象是?
A. DAO
B. DTO
C. VO
D. Mapper
5. 与数据库表 1:1 对应的实体是?
A. VO
B. DTO
C. DAO
D. Converter
6. 本项目对象转换(VO ↔ DAO ↔ DTO)推荐用什么?
A. `BeanUtils.copyProperties`
B. Apache Commons BeanUtils
C. MapStruct
D. 手写 setter/getter
7. Controller 层'不做'以下哪件事?
A. 接收请求
B. 参数校验
C. 业务逻辑编排
D. 返回统一响应 `Result<T>`
8. '修改'接口对应的 HTTP 方法是?
A. GET
B. POST
C. PUT
D. DELETE
9. Controller 新增(add)接口的返回类型必须是?
A. `Result<Void>`
B. `Result<Boolean>`
C. `Result<Long>`(主键 ID)
D. `Result<DAO>`
10. Service 接口和实现类的标准命名是?
A. `XxxService` / `XxxServiceImpl`
B. `IXxxService` / `XxxServiceImpl`
C. `XxxService` / `XxxImpl`
D. `IXxxService` / `XxxImpl`
11. 业务校验失败时,应抛出?
A. `RuntimeException`
B. `BizException`(带枚举或 i18n key)
C. `Error`
D. `Throwable`
12. `@Transactional` 写在同类内 `a()` 调用的 `b()` 方法上,事务是否生效?
A. 生效
B. 不生效(AOP 代理限制)
C. 仅在 DEBUG 模式生效
D. 由 Spring 版本决定
13. Repository 接口继承的父接口是?
A. `BaseMapper<DAO>`
B. `IService<DAO>`
C. `BaseRepository`
D. `CrudRepository`
14. `IService` 自带方法中,按 ID 查询单个是?
A. `findById(Serializable id)`
B. `getById(Serializable id)`
C. `selectById(Long id)`
D. `queryById(Long id)`
七、Mapper 层(第 7 章)— 1 题
15. Mapper XML 的 `namespace` 应填写?
A. Mapper 接口的简单类名
B. Mapper 接口的全限定类名
C. 表名
D. 数据库名
16. 树形结构表中,查询'所有上级'一般使用什么字段?
A. `id`
B. `name`
C. `ancestors`
D. `code`
17. PostgreSQL 中,字符串拼接运算符是?
A. `+`
B. `&`
C. `||`
D. `concat` 函数必须
18. 本项目 Feign 接口统一定义在哪个模块?
A. `hacint-business-system`
B. `hacint-api`
C. `hacint-common-core`
D. `hacint-gateway`
19. 被 Feign 调用的 Controller,推荐加的注解是?
A. `@RequiresLogin`
B. `@RequiresLogin(innerCheck = false)`
C. `@RequiresPermissions`
D. `@Anonymous`
20. 下列做法中,违反本项目硬性规范的是?
A. 新增接口 Service 返回 `Long` 主键
B. Mapper XML `namespace` 写全限定类名
C. 软删除字段 `del_flag` 配合 `@TableLogic`
D. 同模块内不同 Service 之间通过 Feign 互相调用
关闭
更多问卷
复制此问卷