其他

publicclassExceptionTest{classTestExceptionextendsException{}publicvoidrunTest()throwsTestException{}publicvoidtest()/*PointX*/{runTest();}}AtpointXonline4,whichcodecanbeaddedtomakethecodecompile?()A.ThrowsException.B.Catch(Exceptione).C.ThrowsRuntimeExce

题目
publicclassExceptionTest{classTestExceptionextendsException{}publicvoidrunTest()throwsTestException{}publicvoidtest()/*PointX*/{runTest();}}AtpointXonline4,whichcodecanbeaddedtomakethecodecompile?()

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() {?}


Test() {/*code here*/}

第2题:

给定如下代码,下面哪个可以作为该类的构造函数()。 public class Test { ? }

A.public void Test() {?}

B.public Test() {?}

C.public static Test() {?}

D.public static void Test() {?}


Test() {/*code here*/}

第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.*;


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.②④


正确答案:B

第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.


参考答案:A

第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)


参考答案:B

第7题:

publicclassTest {}Whatistheprototypeofthedefaultconstructor?()

A.Test()

B.Test(void)

C.publicTest()

D.publicTest(void)

E.publicvoidTest()


参考答案:C
ThecorrectanswertothisquestionisC.Thedefaultconstructoralwaystakesthesameaccessoftheclass.Inthiscase,theclassispublicandsodoesthedefaultconstructor.

第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.


参考答案:A

第9题:

给出下列java源代码://PointxPublicclassInteresting{}在源代码//pointx处添加()能符合java语法

A.importjava.awt.*

B.packagelocal.util

C.classMoreInteresting{}

D.protectedclassMoreInteresting{}


参考答案:A, B, C