public class demo {
  public static void main(String a[]) {
      B b = (B) new A(); // compiles with the cast, 
                         // but runtime exception - java.lang.ClassCastException
  }}class A {
  public void draw() {
    System.out.println("1");
  }
  public void draw1() {
    System.out.println("2");
  }}class B extends A {
  public void draw() {
    System.out.println("3");
  }
  public void draw2() {
    System.out.println("4");
  }}Java下播
 aluckdog
aluckdog 
					哆啦的时光机
 
					泛舟湖上清波郎朗
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类