• java 11.13


    package top.hyself;
    
    abstract class A{
        private String name;
        public A(String name) {
            this.name = name;
        }
        public String getName() {
            return this.name;
        }
        public abstract void fun();
    }
    class B extends A{
        public B(String name) {
            super(name);
        }
        public void fun() {
            System.out.println(super.getName());
        }
    }
    public class This {
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            B b = new B(null);
            b.fun();
        }
    }
    package top.hyself;
    
    import java.sql.Date;
    
    public abstract class Student {
        private String name;
        private String Class;
        private String date;
    
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String GetClass() {
        return this.Class;
    }
    public void setClass(String Class) {
        this.Class = Class;
    }
    public String getDate() {
        return this.date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    public Student(String name,String Class,String date) {
        this.name = name;
        this.Class = Class;
        this.date = date;
    }
    public Student() {
        super();
    }
    
    @Override
    public String toString() {
        return "Student [name=" + name + "]";
    }
    public abstract String speak();
    
    }
    package top.hyself;
    
    import java.sql.Date;
    
    public class Offence extends Student{
        private String matter;
        public Offence(String name,String Class,String date,String matter) {
            super(name,Class,date);
            this.setMatter(matter);
        }
        @Override
        public String speak() {
            return "我叫:" + super.getName() + " 班级:" + super.GetClass() + " 时间:" + super.getDate() + " 事由:" + this.matter;
        }
        public String getMatter() {
            return matter;
        }
        public void setMatter(String matter) {
            this.matter = matter;
        }
        
    }
    package top.hyself;
    
    public class Demo {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Student stu = new Offence("薛正昊","网站班","2017.11.13","请假");
            print(stu.speak());
        }
    
        private static void print(String speak) {
            System.out.println(speak);
            
        }
    
    }
  • 相关阅读:
    linux | 一次网卡故障处理
    KVM | centos 安装 window 虚拟机
    DNS | named.run文件很大的处理方法
    01
    802.11X用户身份验证
    802.11有线等效加密WEP
    802.11成帧细节
    802.11 MAC基础
    【转载】我为什么放弃了 Linux 内核学习?
    Linux网络编程(一):一个简单的socket程序
  • 原文地址:https://www.cnblogs.com/8ear/p/7865684.html
Copyright © 2020-2023  润新知