Loading...
Loading...
Adaptive Kotlin/Spring backend quiz with 5 questions. Difficulty adjusts based on your answers. Use when reviewing or testing your backend knowledge.
npx skill4agent add itlearning/study-backend backend-quizquestions:
- question: "Which language do you prefer? / 어떤 언어로 진행할까요?"
header: "Language"
options:
- label: "한국어"
description: "한국어로 퀴즈를 풉니다"
- label: "English"
description: "Take the quiz in English"
multiSelect: falseWhat does this code return? Explain your answer.
@Transactional
fun transfer(from: Long, to: Long, amount: Int) {
val sender = accountRepository.findById(from).orElseThrow()
val receiver = accountRepository.findById(to).orElseThrow()
sender.balance -= amount
receiver.balance += amount
}
// What happens if amount > sender.balance?What's wrong with this code? Explain the issue.
@RestController
class UserController(private val userService: UserService) {
@GetMapping("/users/{id}")
fun getUser(@PathVariable id: Long): User {
return userService.findById(id) // returns null if not found
}
}What is the default propagation level of @Transactional in Spring?Write a REST endpoint that meets these requirements:
- POST /api/users
- Accepts a JSON body with name (String) and email (String)
- Validates that email contains '@'
- Returns 201 Created with the saved user
- Returns 400 Bad Request if validation failsCorrect!
Key point: @Transactional with default propagation (REQUIRED) joins
the existing transaction or creates a new one if none exists.Not quite. The answer is "REQUIRED".
REQUIRED means: if a transaction exists, join it; if not, create a new one.
This is the most common behavior and Spring's default.Quiz Results
- Topic: Spring Transaction Management
- Score: 3/5
- Final difficulty: 4/5
- Strengths: @Transactional basics, isolation levels
- Needs work: Propagation types, rollback rules
- Suggestion: Review "transaction propagation" with /backend-study