例5.5.txt

来自「《Java程序设计与应用》-张仕斌-源程序 《Java程序设计与应用》-张仕斌」· 文本 代码 · 共 47 行

TXT
47
字号
//例5.5 有继承时的构造方法。
public class Person
{
	protected String name,phone,address;
	public Person()
	{
		this(" ", " "," ");
	}
	public Person(String aName,String aPhone,String anAddress)
	{
		name = aName;
		phone = aPhone;
		address = anAddress;
	}
}
class Employees extends Person
{
		protected int id;
		protected String workphone;
		public Employees()
		{
			//此处隐含调用构造方法Person()
			this(0,"");
		}
		public Employees(int aId,String aPhone)
		{
			//此处隐含调用构造方法Person()
			id=aId;
			workphone=aPhone;
		}
}
class Professor extends Employees
{
	protected String research;
	public Professor()
	{
		super();
		research="";	
	}
	public Professor(int aId,String aPhone,String aResearch)
	{
		super(aId,aPhone);
		research=aResearch;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?