题目内容

阅读下面代码:public static void main (String [] args){String s;System.out.println(“s=”+s);}编译运行以上程序,结果是()

A. 编译错误
B. 编译通过,但出现运行时错误
C. 正常运行,输出s=null
D. 正常运行,输出s=

查看答案
更多问题

阅读下面代码:class Parent {public int count() { // 第1行return 0;}}public class Test extends Parent {public float count() { // 第2行return 9; // 第3行}}编译时,会出现以下( )情况。

A. 编译通过
B. 在第1行引发编译错误
C. 在第2行引发编译错误
D. 在第3行引发编译错误

阅读下面代码:class Parent1 {Parent1(String s){System.out.println(s);}}class Parent2 extends Parent1{Parent2(){System.out.println("parent2");}}public class Child extends Parent2 {public static void main(String[] args) {Child child = new Child();}}编译并运行Child.java,以上代码运行结果为( )。

A. 编译错误:没有找到构造器Child()
B. 编译错误:没有找到构造器Parent1()
C. 正确运行,没有输出值
D. 正确运行,输出结果为:parent2

阅读下面代码:class Parent {Parent() {System.out.println("parent");}}public class Child extends Parent {Child(String s) {System.out.println(s);}public static void main(String[] args) {Child child = new Child("child");}}上述代码的运行结果为()

A. child
B. child parent
C. parent child
D. 编译错误

阅读下面代码:class Parent {public void count() {System.out.println(10%3);}}public class Child extends Parent{public void count() {System.out.println(10/3);}public static void main(String args[]) {Parent p = new Child();p.count();}}下列选项中的输出结果正确的是( )。

A. 1
B. 1.0
C. 3
D. 3.3333333333333335

答案查题题库