A.ThrowsException.
B.Catch(Exceptione).
C.ThrowsRuntimeException.
D.Catch(TestExceptione).
E.Nocodeisnecessary.
第1题:
给定如下代码,下面哪个可以作为该类的构造函数()。public class Test { ?
A.public void Test() {?}
B.public Test() {?}
C.public static Test() {?}
D.public static void Test() {?}
第2题:
给定如下代码,下面哪个可以作为该类的构造函数()。 public class Test { ? }
A.public void Test() {?}
B.public Test() {?}
C.public static Test() {?}
D.public static void Test() {?}
第3题:
可以在下面代码段point x处写入的是? //point x public class Interesting{ //do something }
A.String str;
B.static int PI=3.14;
C.public class MyClass{//do other thing…}
D.import java.awt.*;
第4题:
阅读下列程序段,不合法的行是______。 class Computer{} class Monitor extends Computer{} class HardDrive extends Computer { public void test() { Monitor a = new Monitor(); Computer b = new Monitor(); HardDrive c = (HardDrive) a; Monitor d = b; } } ①Monitor a = new Monitor(); ②Computer b = new Monitor(); ③HardDrive c = (HardDfive)a; ④Monitor d = b;
A.①②③
B.③④
C.①③④
D.②④
第5题:
importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(Stringargs)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()
A.Thecodewillnotcompile.
B.Theoutputiscaughtexception.
C.TheoutputiscaughtIOException.
D.Theprogramexecutesnormallywithoutprintingamessage.
第6题:
1.publicclassExceptionTest{2.classTestExceptionextendsException{}3.publicvoidrunTest()throwsTestException{}4.publicvoidtest()/*PointX*/{5.runTest();6.}7.}AtPointXonline4,whichcodeisnecessarytomakethecodecompile?()
A.Nocodeisnecessary.
B.throwsException
C.catch(Exceptione)
D.throwsRuntimeException
E.catch(TestExceptione)
第7题:
A.Test()
B.Test(void)
C.publicTest()
D.publicTest(void)
E.publicvoidTest()
第8题:
importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(String[]args)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()
A.Thecodewillnotcompile.
B.Theoutputiscaughtexception.
C.TheoutputiscaughtIOException.
D.Theprogramexecutesnormallywithoutprintingamessage.
第9题:
A.importjava.awt.*
B.packagelocal.util
C.classMoreInteresting{}
D.protectedclassMoreInteresting{}