王吉元-NWPU

导航

 
abstract class Father{
    abstract void show();
}

class Son extends Father
{
    public void show(){
        System.out.println("I am son.");
    }
}
public class start {
public static void main(String[] args)
{
    Father son=new Son();
    son.show();
}
}

输出结果为:

I am son.

*******************************************************************************************************************************

class Father{
    public void show(){
        System.out.println("I am father.");
    }
}

class Son extends Father
{
    public void show(){
        System.out.println("I am son.");
    }
}
public class start {
public static void main(String[] args)
{
    Father son=new Son();
    son.show();
}
}

输出结果为:

I am son.

*******************************************************************************************************************************

class Father{
    
}

class Son extends Father
{
    public void show(){
        System.out.println("I am son.");
    }
}
public class start {
public static void main(String[] args)
{
    Father son=new Son();
    son.show();
}
}

编译错误。

posted on 2013-06-01 16:42  王吉元  阅读(122)  评论(0编辑  收藏  举报