blob: 169a6be104189aae4bedd3358194ac0239e80848 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
class Car {}
class FastCar extends Car {}
class Super {
Car getCar() {
return new Car();
}
}
class Sub extends Super {
FastCar getCar() {
return new FastCar();
}
}
public class CovBaseProgram01 {
public static void main(String[] argv) {
new CovBaseProgram01().run();
}
public void run() {
Super instance_super = new Super();
Sub instance_sub = new Sub();
Car c1 = instance_super.getCar();
Car c2 = instance_sub.getCar();
}
}
// FastCar is a subclass of Car.
// Sub is a subclass of Super.
|