找出这个类无法编译的原因。 public class Main {
interface Fast {
default String mode () { return "fast" ; }
}
interface Safe {
default String mode () { return "safe" ; }
}
static final class Transfer implements Fast , Safe {}
}
查看答案
上一道练习 审查生成的令牌授权器 审查AI代码
问问你的AI 让你的AI把这段代码改成引导式找错练习。
Claude ChatGPT 复制提示词 I am reading "找出这个类无法编译的原因。" on CodeWiki (https://codewiki.com/zh/practice/spotbug/java/interfaces/spotbug-conflicting-defaults/).
Context (verbatim from the page):
"""
public class Main {
interface Fast {
default String mode() { return "fast"; }
}
interface Safe {
default String mode() { return "safe"; }
}
static final class Transfer implements Fast, Safe {}
}
"""
Introduce three subtle bugs into the example above and let me find them. Reveal each answer only after I have guessed.
Answer in 中文. Keep code examples in java. Where you are unsure, say so.