java继承的例子

import java.util.Date;

class Employee
{
	private String name;
	private double salary;
	private Date birthday;
	
	public Employee()
	{
		
	}
	
	public Employee(String name,double salary,Date birthday)
	{
		this.name=name;
		this.salary=salary;
		this.birthday=birthday;
	}
	
	public String getName()
	{
		return name;
	}
	
	public void setName(String name)
	{
		this.name=name;
	}
	
	public double getSalary()
	{
		return salary;
	}
	
	public void setSalary(double salary)
	{
		this.salary=salary;
	}
	
	public Date getBirthday()
	{
		return birthday;
	}
	
	public void setBirthday(Date birthday)
	{
		this.birthday=birthday;
	}
}

class Manager extends Employee
{
	private double bonus;
	
	public Manager()
	{
		
	}
	
	public Manager(String name,double salary,Date birthday,double bonus)
	{
		super(name,salary,birthday);
		this.bonus=bonus;
	}
	
	public double getBonus()
	{
		return bonus;
	}
	
	public void setBonus(double bonus)
	{
		this.bonus=bonus;
	}
}

public class Hello
{
	public static void main(String[] args)
	{
		Employee employee=new Employee("java",100,new Date());

		Manager manager=new Manager("明日科技",3000,new Date(),2000);

		
		System.out.println(employee.getName());
		System.out.println(employee.getSalary());
		System.out.println(employee.getBirthday());
		System.out.println(manager.getName());
		System.out.println(manager.getSalary());
		System.out.println(manager.getBirthday());
	}
}

image
最新2020整理收集的一些高频面试题(都整理成文档),有很多干货,包含mysql,netty,spring,线程,spring cloud、jvm、源码、算法等详细讲解,也有详细的学习规划图,面试题整理等,需要获取这些内容的朋友请加Q君样:909038429
/./*欢迎加入java交流Q君样:909038429一起吹水聊天

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值