【单选题】父类Person有子类Chinese和American,且两个子类都重写了父类中的walk()方法;下列哪项实现了多态编程
A. Chinese c=new Chinese("张三"); American a=new American("John"); B. Chinese c=new Chinese( "张三"); American a=new American("John"); c.walk(); a.walk(); C. Person person1=new Chinese("张三" ); Person person2=new American("John"); D. Person person1=new Chinese("张三" ); Person person2=new American("John"); person1.walk(); person2.walk();
A. Chinese c=new Chinese("张三"); American a=new American("John"); B. Chinese c=new Chinese( "张三"); American a=new American("John"); c.walk(); a.walk(); C. Person person1=new Chinese("张三" ); Person person2=new American("John"); D. Person person1=new Chinese("张三" ); Person person2=new American("John"); person1.walk(); person2.walk();
举一反三
- 父类Person有子类Chinese和American,且两个子类都重写了父类中的walk方法;下列哪项实现了多态编程
- 语句“Person myTest1 = new Person(“张三”,21,60012) ” 与语句“ Person myTest1; myTest1 = new Person(“张三” , 21,60012)”等价。( )
- Communication between an American person and a Chinese person can be called cross-cultural communication.
- 【多选题】定义了如下Person类,下面()程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } } A. Person [ ] list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; B. Person list[ ]=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; C. Person[ ] list={new Person("孙悟空"),new Person("猪八戒")}; D. Person list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")};
- The ______ (communicate) between a chinese person and an American is difficult as there are not many Americans who canspeak Chinese