• 5月5号打卡


    java的继承

    package Music;

    public class Music {
    public void tune(Instrument i){
    i.play();

    }
    public static void main(String args[]){
    Music a=new Music();
    Instrument d=new Instrument();
    a.tune(d);
    Wind b =new Wind();
    b.play2();
    a.tune(b);
    Brass c=new Brass();
    a.tune(c);
    c.play2();
    }
    }

    package Music;

    public class Instrument {
    public void play() {
    // TODO 自动生成的方法存根
    System.out.println("弹奏乐器");
    }

    }
    class Wind extends Instrument{
    public void play(){
    System.out.println("弹奏Wind");
    }
    public void play2(){
    System.out.println("调用wind的play2");
    }
    }
    class Brass extends Instrument{
    public void play(){
    System.out.println("弹奏brass");
    }
    public void play2(){
    System.out.println("调用brass的play2");
    }
    }

    public class E {

    public void main(String[] args) {
    // TODO 自动生成的方法存根
    Monkey b =new Monkey();
    b.speak();
    Poeple c =new Poeple();
    c.speak();
    c.think();
    }
    }
    class Monkey {
    public void speak(){
    System.out.println("咿咿呀呀......");
    }
    }
    class Poeple extends Monkey{
    public void speak(){
    System.out.println("小样的,不错嘛!会说话了!");
    }
    public void think(){
    System.out.println("别说话!认真思考!");
    }
    }

  • 相关阅读:
    Wannafly Camp 2020 Day 2C 纳新一百的石子游戏
    [CF653F] Paper task
    [CCPC2019 哈尔滨] L. LRU Algorithm
    [CCPC2019 哈尔滨] A. Artful Paintings
    [BZOJ4310] 跳蚤
    [BZOJ3277/BZOJ3473] 串
    bugku数字验证绕过正则
    sublime在搜索的时候排除js文件
    bugku逗号过滤注入
    SQL注入之逗号拦截绕过
  • 原文地址:https://www.cnblogs.com/lvzhiqi/p/10816919.html
Copyright © 2020-2023  润新知