/** * Created by xabcd on 2019/2/16. */ interface java_jiekou1 { String name = "张三"; int age = 25; String occupation = "学生"; public abstract String talk(); } class Student5 implements java_jiekou1 { //覆写talk()方法 public String talk() { return "学生——》姓名:"+this.name+"年龄:"+this.age+"职业:"+this.occupation; } }
/** * Created by xabcd on 2019/2/16. */ public class test_jiekou1 { public static void main(String[] args) { Student5 s =new Student5(); System.out.println(s.talk()); } } 结果: 学生——》姓名:张三年龄:25职业:学生