实验代码
public class Cycle{//向上转型
static void ride(){
System.out.println("Cycle has ride");}
public static void main(String[] args){
Cycle c = new Unicycle();
Cycle y = new Bicycle();
Cycle l = new Tricycle();
Cycle cycle = new Cycle();
c.ride();
y.ride();
l.ride();
cycle.ride();
}
}
class Unicycle extends Cycle{
static void ride(){