`

关于类继承的一道面试题

阅读更多
一道面试题,当时没有看出来。在此记录一下。

写出下列程序的运行结果
public class Cat
{  
  void mi( ) throws NullPointerException  {
    System.out.println( “Cat mi mi .. “ );
  }
}
public class SmallCat extends Cat
{int i=8;
  void mi( ) throws Exception
  {
    System.out.println( “SmallCat mi mi .. “ );
  }
  public static void main( String[] a ) throws Exception
  {
    Cat cat = new SmallCat();
    cat.mi();
  }
}
==编译错误
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics