1.publicclasstest{2.publicstaticstringoutput=”3.4.publicstaticvoidfoo(inti){5.try{6.if(i==1){7.thrownewException();8.}9.output+=1”;10.}11.catch(Exceptione){12.output+=2”;13.return;14.}15.finally(16.output+=3”;17.)18.output+=4”;19.}20.21.publicstaticvoidmain(stringargs[])(22.foo(0);23.foo(1);24.25.)26.}Whatisthevalueofthevariableoutputatline24?()
1.publicclasstest{
2.publicstaticstringoutput=”
3.
4.publicstaticvoidfoo(inti){
5.try{
6.if(i==1){
7.thrownewException();
8.}
9.output+=1”;
10.}
11.catch(Exceptione){
12.output+=2”;
13.return;
14.}
15.finally(
16.output+=3”;
17.)
18.output+=4”;
19.}
20.
21.publicstaticvoidmain(stringargs[])(
22.foo(0);
23.foo(1);
24.
25.)
26.}
Whatisthevalueofthevariableoutputatline24?()
相关考题:
在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class
publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?() A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.
publicclassTest {}Whatistheprototypeofthedefaultconstructor?() A.Test()B.Test(void)C.publicTest()D.publicTest(void)E.publicvoidTest()
packagetest1;publicclassTest1{staticintx=42;}packagetest2;publicclassTest2extendstest1.Test1{publicstaticvoidmain(String[]args){System.out.println(x=+x);}}Whatistheresult?() A.x=0B.x=42C.Compilationfailsbecauseofanerrorinline2ofclassTest2.D.Compilationfailsbecauseofanerrorinline3ofclassTest1.E.Compilationfailsbecauseofanerrorinline4ofclassTest2.
下列哪个选项的java源文件代码片段是不正确的?A.package testpackage; public class Test{ }B.import java. io. *; package testpaekage; public class Test { }C.import java.io.*; class Person { } public class Test { }D.import java.io.*; import java. awt.*; public class Test{ }
下列( )选项的java源文件代码片段是不正确的。A.package testpackage; publicClass Test{}B.import java.io.*; package testpackage: publicClass Test{}C.import java.io.*; Class Person{} publicClass Test{}D.import java.io.*; import java.awt.*; publicClass Test{}
下列哪个选项的java源文件程序段是不正确的? ( )A.package testpackage; public class Test{ }B.import java.io.*; package testpackage; public class Test{ }C.import java.i.*; class Person{} public class Test{ }D.import java.io.*; import java.awt.*; public class Test { }
在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}
下面的哪些java源文件代码片断是对的?()A.package testpackage; public class Test{//do something...}B.import java.io.*; package testpackage; public class Test{// do something...}C.import java.io.*; class Person{// do something...} public class Test{// do something...}D.import java.io.*; import java.awt.*; public class Test{// do something..}
指明程序的错误,并书写修改后的正确代码。 public class Test{ public static void method(int x){ } public static void method(int y){return y; } }