岗位:Java 后端开发(Associate)
平台:HackerRank
内容:Java + SQL + Debugging
时长:70 分钟
Section 1 – Java 选择题(共 4 题)
题型包含单选和多选,主要考察核心 Java 知识点:
- 一个关于 Stack 和 Queue 行为的代码片段,要求根据插入/移除顺序预测输出结果。
- Vector 和 ArrayList 的区别,重点是同步机制和性能。
- Java 异常体系的根本逻辑,包括 Throwable、Error 和 Exception 的关系。
- Java 垃圾回收的基本知识,比如对象何时变得不可达、何时被回收。
Section 2 – SQL 编程题
提供两张表:
- 表 1:id, email
- 表 2:id, date
题目要求:
写一条 SQL 查询,获取所有日期落在周末(周六或周日)对应的 email。考察 JOIN、日期函数和条件筛选逻辑。
我的解法:
SELECT t1.email, DAYNAME(t2.date) AS day_name
FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id
WHERE DAYOFWEEK(t2.date) IN (1, 7);
Section 3 – Java debug调试任务
You were given a small Java web application with:
Controller, Service, Repository, Unit tests
Objective:
Fix the bugs in the code so that all unit tests pass. This tested understanding of Spring Boot annotations, dependency injection, and logic errors.
Section 4 – 密码验证编程题
给定一个密码列表,要求根据一组规则筛选出合法密码:
密码规则:
长度必须大于 5
不能只包含纯字母或纯数字,仅包含特殊字符(如 @#$%)的密码也被视为合法。