package com.test;
/**
*
6、 声明类Person,包含2个成员变量:name、age。定义函数sayHello(),调用时输出:我叫***,今年***岁了。声明类Chinese继承Person。
*
*/
public class Test5 {
public static void main(String[] args) {
Chinese chinese = new Chinese();
chinese.age = 15;
chinese.name = "网络";
chinese.sayHello();
}
}
class Person{
public String name;
public int age;
public void sayHello(){
System.out.println("我叫"+name+",今年"+age+"岁了");
}
}
class Chinese extends Person{
} |
|