1 Star 0 Fork 0

Java45_张奭/javaoop继承

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Person03.java 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
package cn.hfkh.oop04;
class Person03 {
String name = "李光"; //姓名
public Person03(){
//super();写不写该句,效果一样
System.out.println("execute Person03()");
}
public Person03(String name){
this.name = name;
System.out.println("execute Person03(name)");
}
}
class Student extends Person03{
String school = "北大青鸟"; //学校
public Student(){
//super();写不写该句,效果一样
System.out.println("execute Student()");
}
public Student(String name, String school){
super(name);
this.school = school;
System.out.println("execute Student(name,school)");
}
}
class PostGraduate extends Student{
String guide; //导师
public PostGraduate(){
System.out.println("execute PostGradute()");
}
public PostGraduate(String name,String school,String guide){
super(name,school);
this.guide = guide;
System.out.println("excute PostGraduate(name,school,guide)");
}
}
class TestInherit{
public static void main(String[] args) {
PostGraduate pgdt = null;
pgdt = new PostGraduate();
System.out.println();
pgdt = new PostGraduate("刘志同","北京大学","王老师");
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangshi66/javaoopJiCheng.git
[email protected]:zhangshi66/javaoopJiCheng.git
zhangshi66
javaoopJiCheng
javaoop继承
master

搜索帮助