题目内容

如下程序的运行后,y的值是()intx=2,y=10;switch(x){case0:y=x*x;case2:y=y/2;case6:y=y-x;}

A. 4
B. 5
C. 3
D. 0

查看答案
更多问题

共打印了“好好学习,天天向上”()次inti=1;while(i<=100){System.out.println("第"+i+"遍写:好好学习,天天向上!");i++;}

A. 100
B. 99
C. 101
D. 0

编译运行如下Java代码,输出结果是()classBase{ publicvoidmethod(){System.out.print("Basemethod"); } } classChildextendsBase{publicvoidmethodB(){ System.out.print("ChildmethodB"); }} classSample{ publicstaticvoidmain(String[]args){Basebase=newChild(); base.methodB(); }}

A. Basemethod
B. ChildmethodB
C. BasemethodChildMethodB
D. 编译错误

(方法覆盖)有如下代码classSuper {publicvoidmethod()throwsIOException {}}publicclassMySubextendsSuper {@Overridepublicvoidmethod()//_1_______________________{}}问:在//1处,填入以下________________________代码编译无法通过

A. throws java.io.IOException
B. throws java.io.FileNotFoundException, java.io.EOFException
C. throws java.sql.SQLException
D. 不抛出任何异常,即什么都不填写。

给出以下代码,请问该程序的运行结果是什么?( )class Example {String s = "Outer";public static void main(String[] args) {S2 s2 = new S2();s2.display();}}class S1 {Strings = "S1";void display() {System.out.println(s);}}class S2 extends S1{String s = "S2";}请选择一个正确答案:

A. (1)S1
B. (2)S2
C. (3)Null
D. (4)Outer

答案查题题库