Java 继承

package com.wc.lianxi;


public class test1 {
public static void main(String[] args){
human1 h = new human1();
h.play();
h.sleep();
h.eat();
}
}


class animal1 {
String color;
int age;
String job;

animal1(int x){
System.out.println(x);
}

animal1(String color,int age,String job){
this.color =color;
this.age =age;
this.job =job;
System.out.println("一个 "+age+"岁的"+color+"人"+job+"\t父构造方法");
}

void eat(){
System.out.println("父吃饭");
}

void sleep(){
System.out.println("父睡觉");
}
void play(){
System.out.println("父玩耍");
}
}






class human1 extends animal1{
human1(){
super("黑",18,"worker");
}


void play(){
System.out.println("子玩耍");
}
void eat(){
System.out.println("子吃饭");
}
void sleep(){
System.out.println("子睡觉");
}
 
 
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值