1)多态的三种手段:上转型,重载,重写。
2)域和静态方法不具备多态性。
class Shape {
int size = 5;
public void draw() {
System.out.println("shape draw");
}
public static void dispose() {
System.out.println("shape dispose");
}
}
class Circle extends Shape {
int size = 6;
public void draw() {
System.out.println("circle draw");
}
public static void dispose() {
System.out.println("circle dispose");
}
}
public class NonePolymorphism {
public static void main(String[] args) {
Shape test = new Circle();
test.draw();
test.dispose();
System.out.println(test.size);
}
}