在Java中,有如下两个类Student和Person。如果Student是Person的子类,则下列声明对象x的语句中错误的是()。
A: Person x = new Student()
B: Person x = new Person()
C: Student x = new Person()
D: Student x = new Student()
A: Person x = new Student()
B: Person x = new Person()
C: Student x = new Person()
D: Student x = new Student()
举一反三
- 在Java中,有如下两个类Student和Person。如果Student是Person的子类,则下列声明对象x的语句中错误的是()
- 假设 Student类为Person类的子类,则下面()创建对象是错误的。 A: Studentbase = new Student() B: Personbase = new Person() C: Personchild = new Student() D: Studentchild = new Person();
- Student类是Person类的子类,分析下面语句,转型是否正确: Student s =(Student)new Person("张三", 23);
- python中,下列哪种语法表示Student从Person中继承。( ) A: class Student: Person B: class Student extends Person C: class Student (Person) D: class Student: class Person
- 类Teacher和Student是类Person的子类