Java 继承
来源:互联网 发布:图后期制作软件 编辑:程序博客网 时间:2024/06/01 09:53
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("子睡觉");
}
}
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
- Java继承
- JAVA-继承
- java 继承
- Java继承
- Java 继承
- JAVA继承
- java继承
- java/继承
- java 继承
- java继承
- java继承
- JAVA-继承
- Java继承
- java 继承
- JAVA 继承
- 【继承】 JAVA
- Java继承
- Java继承
- Android Studio 快捷键
- JavaScript中的DOM节点操作
- AndroidStudio修改包名和项目名称
- HTML5 5 表单
- HashTable/HashMap/ConcurrentHashMap
- Java 继承
- 常量
- PyCharm使用技巧:Shift + Tab(向左缩进)
- Java学习笔记-《Java程序员面试宝典》-第四章基础知识-4.5字符串与数组(4.5.4-4.5.6)
- Web Notification Demo
- spring之注入对象
- 第三方登录资料
- ctrl键
- stack---停车场