41. コンストラクタの呼び出し
? 正しいコンストラクタの呼び出し
public static void main(String[] args) {
Rectangle r = new Rectangle();
Rectangle s = new Rectangle(123, 45);
NamedRectangle nr = new
NamedRectangle();
NamedRectangle ns = new
NamedRectangle("name");
}
77. 抽象クラス
abstract class Player {
public abstract void play();
public void loop(int n) {
for (int i = 0; i < n; i++) {
play();
}
}
}
78. playメソッドの実装
public class TextPlayer extends Player {
String text;
public TextPlayer(String text) {
this.text = text;
}
@Override
public void play() {
System.out.println(text);
}
public static void main(String[] args) {
TextPlayer player = new TextPlayer("こんにちは");
player.loop(3);
}
}