• 2017.11.20


      1 abstract class A{
      2     private String name;
      3     public A(String name) {
      4         this.name = name;
      5     }
      6     public String getName() {
      7         return this.name;
      8     }
      9     public abstract void fun();
     10 }
     11 class B extends A{
     12     public B(String name) {
     13         super(name);
     14     }
     15     public void fun() {
     16         System.out.println(super.getName());
     17     }
     18 }
     19 public class L {
     20     public static void main(String[] args) {
     21         // TODO Auto-generated method stub
     22         B b = new B(null);
     23         b.fun();
     24     }
     25 }
     26 import java.sql.Date;
     27 
     28 @SuppressWarnings("unused")
     29 public abstract class Y {
     30     private String name;
     31     private String Class;
     32     private String date;
     33 
     34 public String getName() {
     35     return this.name;
     36 }
     37 public void setName(String name) {
     38     this.name = name;
     39 }
     40 public String GetClass() {
     41     return this.Class;
     42 }
     43 public void setClass(String Class) {
     44     this.Class = Class;
     45 }
     46 public String getDate() {
     47     return this.date;
     48 }
     49 public void setDate(String date) {
     50     this.date = date;
     51 }
     52 public Y(String name,String Class,String date) {
     53     this.name = name;
     54     this.Class = Class;
     55     this.date = date;
     56 }
     57 public Y() {
     58     super();
     59 }
     60 
     61 @Override
     62 public String toString() {
     63     return "Student [name=" + name + "]";
     64 }
     65 public abstract String speak();
     66 
     67 }
     68 import java.sql.Date;
     69 @SuppressWarnings("unused")
     70 public class H extends Y{
     71     private String matter;
     72     public H(String name,String Class,String date,String matter) {
     73         super(name,Class,date);
     74         this.setMatter(matter);
     75     }
     76     @Override
     77     public String speak() {
     78         return "我叫 " + super.getName() + " 今年 " + super.GetClass() + " 身高 " + super.getDate() + " 体重 " + this.matter;
     79     }
     80     public String getMatter() {
     81         return matter;
     82     }
     83     public void setMatter(String matter) {
     84         this.matter = matter;
     85     }
     86     
     87 }
     88 public class K {
     89 
     90     public static void main(String[] args) {
     91         // TODO Auto-generated method stub
     92         Y stu = new H("孙思齐,","35岁了,","188cm,","70KG。");
     93         print(stu.speak());
     94     }
     95 
     96     private static void print(String speak) {
     97         System.out.println(speak);
     98         
     99     }
    100 
    101 }
    
     

  • 相关阅读:
    vue2.0阻止事件冒泡
    IconFont 图标制作和使用
    Gulp入门教程
    伪类实现特殊图形,一个span加三角形
    Vue渲染列表,在更新data属性后,列表未更新问题
    理解Array.prototype.slice.call(arguments)
    ;(function(){ //代码})(); 自执行函数开头为什么要加;或者!
    Hexo 搭建博客 本地运行 常见报错及解决办法
    说说JSON和JSONP,也许你会豁然开朗
    数组去重的常用方法
  • 原文地址:https://www.cnblogs.com/stenber/p/7865946.html
Copyright © 2020-2023  润新知