You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CovBaseProgram01.java 543B

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