以下程序的输出结果为 。 class Person { public Person() { System.out.println("Person"); } } class Student extends Person { public Student() { System.out.println("Student"); } } class CollegeStudent extends Student { public CollegeStudent() { System.out.println("CollegeStudent"); } } public class Test { public static void main(String[] args) { CollegeStudent cs = new CollegeStudent(); } }
第1题
以下程序的运行结果是 class Person{ public Person(){ System.out.println(“this is a Person”); } } public class Teacher extends Person{ private String name=”tom”; public Teacher(){ System.out.println(“this is a teacher”); super(); } public static void main(String[] args){ Teacher teacher = new Teacher(); System.out.println(this.name); } }
A、this is a Person this is a teacher tom
B、this is a teacher this is a Person tom
C、运行出错
D、编译有两处错误
第2题
classPerson{
Person(){
System.out.print("Thisisaperson.");
}
}
publicclassStudentextendsPerson{
Student(){
System.out.print("Thisisastudent");
}
publicstaticvoidmain(String[]args){
Studentstu=newStudent();
}
}
运行结果是:
第3题
A、没有输出结果
B、输出:构造
C、输出:static 构造
D、输出:static
第4题
A、A.输出1个hello
B、B.输出2个hello后会抛出异常
C、C.输出3个hello后会抛出异常
D、D.不会输出hello,直接抛出异常
第5题
A、A.无结果输出
B、B.输出 null
C、C.输出 hello
D、D.编译失败
第6题
A、当编译时会发生错误
B、编译不会发生错误但执行是会发生错误
C、输出结果为0
D、不会输出结果
第7题
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出为0
D.输出为空
第8题
A. 编译将产生错误
B. 编译时正确,但运行时将产生错误
C. 正确,输出0
D. 正确,输出?null
第9题
第10题
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!