c.java
来自「JAVA编程思想第四版英文原版习题答案. pdf原版的」· Java 代码 · 共 21 行
JAVA
21 行
// reusing/Ex5/C.java
// TIJ4 Chapter Reusing, Exercise 5, page 245
/* Create two classes, A and B, with default constructors (empty argument
* lists) that announce themselves. Inherit a new class called C from A, and
* create a member of class B inside C. Do not create a constructor for C. Create
* an object of class C and observe the resluts.
*/
import static org.greggordon.tools.Print.*;
class A { A(){ println("A()");} }
class B extends A { B(){ println("B()");} }
class C extends A {
B b = new B(); // will then construct another A and then a B
public static void main(String[] args) {
C c = new C(); // will construct an A first
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?