zoukankan      html  css  js  c++  java
  • JAVA之多态性

    package com.test;

    //多态性

    public class test4 {

        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub

      Animal an = new Cat();

      an.cry();

      an = new Dog();

      an.cry();
        }
    }
        
        class Animal
        {
    //        private String name;
    //        
    //        private String color;
    //        
    //        private float weight;
    //        
            public void cry()
            {
                System.out.println("我是动物,我不知道怎么叫!!");
            }
        }
        
        class Cat extends Animal
        
        {
            public void cry()
            {
                System.out.println("我是猫,我的叫声是喵喵!!");
            }
        }
        
        class Dog extends Animal
        {
            public void cry()
            {
                System.out.println("我是狗,我的叫声是汪汪!!");
            }
        }

  • 相关阅读:
    1.28
    1.27
    1.26
    如果给你以下功能怎么测试
    测试面试题
    对h5页面的测试方式
    完美解决linux下Django报错Error: That port is already in use.
    KeyError:使用Python的Appium中的“ touchAction” 错误码
    Appium自动化测试
    selenium IDE使用
  • 原文地址:https://www.cnblogs.com/milantgh/p/4036641.html
Copyright © 2011-2022 走看看