-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDog.java
More file actions
27 lines (23 loc) · 582 Bytes
/
TestDog.java
File metadata and controls
27 lines (23 loc) · 582 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package java04;
class Animal1{
public void move(){
System.out.println("动物可以移动");
}
}
class Dog1 extends Animal{
public void move(){
System.out.println("狗可以跑和走");
}
public void bark(){
System.out.println("狗可以吠叫");
}
}
public class TestDog{
public static void main(String args[]){
Animal1 a = new Animal1(); // Animal 对象
Dog1 b = new Dog1(); // Dog 对象
a.move();// 执行 Animal 类的方法
b.move();//执行 Dog 类的方法
b.bark();
}
}