32 lines
672 B
Java
32 lines
672 B
Java
// reuse/Cartoon.java
|
|
// (c)2016 MindView LLC: see Copyright.txt
|
|
// We make no guarantees that this code is fit for any purpose.
|
|
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
|
|
// Constructor calls during inheritance
|
|
|
|
class Art {
|
|
Art() {
|
|
System.out.println("Art constructor");
|
|
}
|
|
}
|
|
|
|
class Drawing extends Art {
|
|
Drawing() {
|
|
System.out.println("Drawing constructor");
|
|
}
|
|
}
|
|
|
|
public class Cartoon extends Drawing {
|
|
public Cartoon() {
|
|
System.out.println("Cartoon constructor");
|
|
}
|
|
public static void main(String[] args) {
|
|
Cartoon x = new Cartoon();
|
|
}
|
|
}
|
|
/* Output:
|
|
Art constructor
|
|
Drawing constructor
|
|
Cartoon constructor
|
|
*/
|