zoukankan      html  css  js  c++  java
  • 1.20作业

    父类

    package com.hanqi;
    
    
    public class father {
        public father (){
            //System.out.println("父类的构造函数");
        }
         private String x1;
         
         private String x2;
         
         public String getX1() {
           return x1;
         }
         public void setYuyin(String x1) {
             this.x1 = x1;
         }
         public String getX2() {
             return x2;
         }
         public void setYuhui(String x2) {
             this.x2 = x2;
         }
        
         void   y1()
         {
             System.out.println("方法一");
         }
         void y2()
         {
             System.out.println("方法二");
         }
    
    }

    子类覆盖

    package com.hanqi;
    
    public class Son extends father {
        public Son()
        {
            System.out.println("子类构造函数");
        }
        public void y2()
        {
            System.out.println("子类重写方法");
        }
    
        
        
    }

    向上转型

    package com.hanqi;
    
    public class ceshi2 {
    
        public static void main(String[] args) {
            // TODO 自动生成的方法存根
              Son zl = new Son();
                
                zl.y1();
                
                zl.y2();
                
               father fl = new father();
               
               fl.y1();
               
               fl.y2();
        }
    
    }

  • 相关阅读:
    PHP array_intersect_uassoc
    PHP array_intersect_key
    PHP array_intersect_assoc
    PHP array_flip
    PHP array_filter
    PHP array_fill
    PHP array_fill_keys
    Android4.0-Fragment框架实现方式剖析
    Fragment 生命周期
    WebView
  • 原文地址:https://www.cnblogs.com/zhanghaozhe8462/p/5146420.html
Copyright © 2011-2022 走看看