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

    public class ful {
        
        ful(String argus)
        {
             System.out.println("父类的构造函数 ");
        }
        ful()
        {
                      
        }
             
                 private String di1;
                 
                 private String di2;
                 
                 public String getDi1() {
                   return di1;
                 }
                 public void setYuyin(String di1) {
                     this.di1 = di1;
                 }
                 public String getDi2() {
                     return di2;
                 }
                 public void setYuhui(String di2) {
                     this.di2 = di2;
                 }
                
                 void   di1()
                 {
                     System.out.println("父类第一方法");
                 }
                 void di2()
                 {
                     System.out.println("父类第二方法");
                 }
    }

    在子类中覆盖第二个方法

    package lianxi;
    
    public class zil extends ful {
        
        public zil()
        {
            System.out.println("子类的构造函数");
        }
        public void di2()
        {
            System.out.println("子类重写的方法");
        }
    
    }

    向上转型并调用

    public class Y1  {
        
        public static void main(String[] args)
        {
            zil zl = new zil();
            
            zl.di1();
            
            zl.di2();
            
           ful fl = new zil();
           
           fl.di1();
           
           fl.di2();
            
        }

    子类的构造函数
    父类第一方法
    子类重写的方法
    子类的构造函数
    父类第一方法
    子类重写的方法

  • 相关阅读:
    Qt高级编码约定
    QTextCodec::codecForLocale
    无边框窗口拖动代码
    QString QByteArray char 之间的转换
    Qt 程序发布指南
    qt demo pro
    snort vtun performance on vm
    xhEditor用法
    MVC控制器使用总结
    第七章 模态框
  • 原文地址:https://www.cnblogs.com/baozhaba-xianchong/p/5146363.html
Copyright © 2011-2022 走看看