OnJava8-Examples/reuse/Chess.java

31 lines
529 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// reuse/Chess.java
2015-06-15 17:47:35 -07:00
// Inheritance, constructors and arguments.
class Game {
Game(int i) {
2015-11-03 12:00:44 -08:00
System.out.println("Game constructor");
2015-06-15 17:47:35 -07:00
}
}
class BoardGame extends Game {
BoardGame(int i) {
super(i);
2015-11-03 12:00:44 -08:00
System.out.println("BoardGame constructor");
2015-06-15 17:47:35 -07:00
}
}
public class Chess extends BoardGame {
Chess() {
super(11);
2015-11-03 12:00:44 -08:00
System.out.println("Chess constructor");
2015-06-15 17:47:35 -07:00
}
public static void main(String[] args) {
Chess x = new Chess();
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
Game constructor
BoardGame constructor
Chess constructor
2015-09-07 11:44:36 -06:00
*/