网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
考虑下列Java代码:classA{publicstaticvoidmain(String[]args){try{System.out.println("Hello,World!");}}}其中的错误是()。

A.没有catch或finally块

B.没有抛出异常的代码不能出现在try代码块内

C.如果没有catch块而使用try,main()会总是抛出异常.

D.classA没有throwsIOException


参考答案

更多 “ 考虑下列Java代码:classA{publicstaticvoidmain(String[]args){try{System.out.println(Hello,World!);}}}其中的错误是()。 A.没有catch或finally块B.没有抛出异常的代码不能出现在try代码块内C.如果没有catch块而使用try,main()会总是抛出异常.D.classA没有throwsIOException ” 相关考题
考题 分析下列代码:ClassA{Publicstaticvoidmain(String[]args){method();}staticvoidmethod(){try{System.out.println(Hello);}finally{System.out.println(good-bye);}}}编译运行后,输出结果是()。 A.HelloB.good-byeC.Hellogod-byeD.代码不能编译

考题 分析下列java代码ClassA{Publicstaticvoidmain(String[]args){Method();}Staticvoidmethod(){try{System.out.println(hello”)}finally{System.out.println(good-bye”);}}}编译运行后,输出结果是() A.“hello”B.“good-bye”C.“hello”“good-bye”D.代码不能编译

考题 考虑下列Java代码:ClasscA{Publicstaticvoidmain(String[]args){Try{System.out.println(hello,world”)}}}其中错误的是()。 A.没有catch或finally块B.没有抛出异常的代码不能出现在try代码块内C.如果没有catch块而使用try,main()会总是抛出异常.D.classA没有throwsIOException

考题 分析下列Java代码:classA{publicstaticvoidmain(String[]args){method();}staticvoidmethod(){try{System.out.println(Hello);System.exit(0);}finally{System.out.println(good-bye);}}}编译运行后,输出结果是()。A.HelloB.good-byeC.Hello后面是good-byeD.代码不能编译

考题 publicstaticvoidmain(String[]args){try{args=null;args[0]=test”;System.out.println(args[0]);}catch(Exceptionex){System.out.println(”Exception”);}catch(NullPointerExceptionnpe){System.out.println(”NullPointerException”);}}Whatistheresult?()A.testB.ExceptionC.Compilationfails.D.NullPointerException

考题 publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?() A.FinallyB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.

考题 清在下划线处填入代码,使程序正常运行并且输出“Hello!”classTesl______{publicstaticvoidmain(string[]args){Test=newTest();t.start();}Pubhcvoidrun(){System.out.println("Hello!");}}

考题 阅读下列代码,选出该代码段正确的文件名()。 class A{ void method1(){ System.out.println("Method1 in class A"); } } public class B{ void method2(){ System.out.println("Method2 in class B"); } public static void main(String[] args){ System.out.println("main() in class B"); } }A.javaB.A.classC.B.javaD.B.class

考题 如果在hello.java 中撰写以下程序代码: public class Hello { public static void main(String[] args) { System.out.println("Hello World"); } } 以下描述正确的是()。A.执行时显示Hello WorldB.执行时出现NoClassDefFoundErrorC.执行时出现找不到主要方法的错误D.编译失败