• 2021-04-14
    已知

    import java.io.*;

    class Person{

    public static void print(){System.out.print("Person");}

    }

    class Employee extends Person{

    public void print(){

    System.out.print("Employee");}

    }

    class Manager extends Employee{

    public void print(){

    System.out.print("Manager");}

    }

    public class Test{

    public static void main(String[] args){

    Manager man = new Manager();

    Employee emp1 = new Employee();

    Employee emp2 = (Employee)man;

    Person person = (Person)man;

    emp2.print();

    System.out.print("#");

    person.print();}

    }

    对于以上代码,其输出结果是

  • 举一反三