1 class Fruit{
2 public double weight;
3 public void info(){
4 System.out.println(weight);
5 }
6 }
7
8 public class Apple extends Fruit{
9 public static void main(String[] args) {
10 Apple a = new Apple();
11 a.weight = 56;
12 a.info();
13 }
14 }
2 public double weight;
3 public void info(){
4 System.out.println(weight);
5 }
6 }
7
8 public class Apple extends Fruit{
9 public static void main(String[] args) {
10 Apple a = new Apple();
11 a.weight = 56;
12 a.info();
13 }
14 }
class Bird{
public void fly(){
System.out.println("我在天空中自由自在的飞翔……");
}
}
public class Ostrich extends Bird{
public void fly(){
System.out.println("我只能在地上奔跑……");
}
public static void main(String[] args) {
Ostrich os = new Ostrich();
//这里Ostrich对象的fly方法,将输出“我在地上奔跑……”
os.fly();
}
}
public void fly(){
System.out.println("我在天空中自由自在的飞翔……");
}
}
public class Ostrich extends Bird{
public void fly(){
System.out.println("我只能在地上奔跑……");
}
public static void main(String[] args) {
Ostrich os = new Ostrich();
//这里Ostrich对象的fly方法,将输出“我在地上奔跑……”
os.fly();
}
}