对于下列代码,下列哪个叙述是正确的
class People {
People(int m) { }
}
class Student extends People { }
class People {
People(int m) { }
}
class Student extends People { }
举一反三
- 下面关于子类继承父类,正确的是( )。 A: public class Student extends People{} B: public class Student implements People{} C: public class Student extends Teacher People{} D: 以上都不正确
- 阅读程序题(给出【代码】注释标注的代码的输出结果)interface Com {int add( int a, int b);}abstract class People {abstract int add( int a, int b);}class Student extends People implements Com{public int add(int a,int b) {return a + b;}}public class 习题5_阅读3 {public static void main(String args[ ]) {Student stu = new Student ();Com com = stu;int m = com.add(12,6);People p = stu;int n = p.add(12,8);System.out.printf("%d:%d",m,n); //【代码】}}
- 对于下列代码,下列哪个叙述是正确的? class A { public int i=0; A(int m) { i = 1; } } public class B extends A { B(int m) { i = 2; } public static void main(String args[]){ B b = new B(100); System.out.println(b.i); //【代码】 } }
- python中,下列哪种语法表示Student从Person中继承。( ) A: class Student: Person B: class Student extends Person C: class Student (Person) D: class Student: class Person
- 对于下列代码,下列哪个叙述是正确的?class A { public int i=0; A(int m) { i = 1; } } public class B extends A { B(int m) { i = 2; } public static void main(String args[]){ B b = new B(100); System.out.println(b.i); //【代码】 } } A: 程序提示编译错误。 B: 编译无错误,【代码】输出结果是0。 C: 编译无错误,【代码】输出结果是1。 D: 编译无错误,【代码】输出结果是2。