Test01.java 336 B

123456789101112131415161718
  1. package course.polymorphism;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title Test01
  6. * @description
  7. * @create 2026/7/24
  8. */
  9. public class Test01 {
  10. public static void main(String[] args) {
  11. //多态---父类的引用指向子类的对象
  12. Animal animal=new Dog();
  13. animal.eat();
  14. animal.sleep();
  15. }
  16. }