单选题import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()A The code will not compile.B The output is caught exception.C The output is caught IOException.D The program executes normally without printing a message.

单选题
import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()
A

 The code will not compile.

B

 The output is caught exception.

C

 The output is caught IOException.

D

 The program executes normally without printing a message.


参考解析

解析: 暂无解析

相关考题:

下列Java源程序结构中前三种语句的次序,正确的是A.import, package, public classB.import必为首,其他不限C.public class, import, packageD.package, import, public class

将下面Applet程序补充完整。import java.awt.*:import java.apptet.*;public class Hi ______ {public void paint(Graghics g) {g.drawstring("Hi!",2.5,2.5);}}

下列Applet在坐标 ( 20,20) 处显示一幅GIF图像,在横线处填入正确的语句。import java. net.*;import java. awt.*;import java. applet.*;public class Test extends Applet {Image IMG;public void init() {URL url = getDocumentBase ();String name="IMG.gif";【 】}public void paint(Graphics g) {g. drawImage ( IMG,20,20,this);}}

在下面Java Applet程序的下画线处填入代码,使程序完整并能够正确运行。import java.applet.*;import java.awt.*;public class HelloWorld ______ {public void paint(Graphics g) {g.drawString("Hello World!",25,25);}}

下列代码的下划线处应填入的方法名是______。import java.awt.*;import java.applet.*;public class Hello extends Applet{public void______(Graphics g){g.drawString("How are you!", 10, 10);}}A) repaintB) printlnC) paintD) showA.B.C.D.

下列程序构造了一个 Swing Applet ,请在下划线处填入正确的代码Import javax.swing.*;Import java.awt.*;Public class SwingApplet extends 【 13 】 {Jlabel l = new Jlabel ( “ This is a Swing Applet. ” );Public void init(){Container contentPane = getContentPane();contentPane.add(1);}}

下列哪个选项的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{ }

请将下面的Applet程序补充完整。import java. awt. *;import java. applet. *;public class Hi【 】{public void paint(Graphics g){g. drawString("Hi!", 25, 25);}}

下列代码的输出结果是( )。class parent{void printme(){System.out.println("parent");}}class child extends parent{void printme(){System. out.println("child");}void printall(){super, printme();this.printme();printme();}}public class test{public static void main(String args[]){child myc=new child();myc.printall();}}A.import java.awt.*;B.import java.applet.applet;C.import java.io.*;D.import java, awt.graphics;

下列哪个选项的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 { }

下面程序构造了一个Swing Applet,在下画线处填入正确的代码。import javax.swing.*;import java.awt.*;public class SwingApplet extends ______ {JLabel 1=new JLabel("This is a Swing Applet.");public void init() {Container contentPane=getContentPane();contentPane.add(1);}}

请在下划线处填入代码,使程序能够正确运行。import java .awt.*;import java .applet.*;public class SayHi extends Applet{public void【 】(Graphics g){g .drawString(“Hi!”20,20);}}

给出下列java源代码:  //Point x  Public class Interesting{}  在源代码//point x处添加()能符合java语法 A、import java.awt.*B、package local.utilC、class MoreInteresting{}D、protected class MoreInteresting{}

在J2EE中,有如下代码在Servlet1.java中。  import javax.servlet.*;  import javax.servlet.http.*;  import java.io.IOException;  import java.io.PrintWriter;  public class Servlet1 extends HttpServlet {    public void init()  throws ServletException {   }  public void service(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {      PrintWriter out = response.getWriter();      out.println("hello!");   } }   假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。 A、编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过B、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”C、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字D、编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

在单一文件中import、class和package的正确出现顺序是()A、package,import,classB、class,import,packageC、import,package,classD、package,class,import

public class ExceptionTest {   class TestException extends Exception {}   public void runTest () throws TestException {}   public void test () /* Point X*/ {   runTest ();   }   }   At point X on line 4, which code can be added to make the code compile?()  A、 Throws Exception.B、 Catch (Exception e).C、 Throws RuntimeException.D、 Catch (TestException e).E、 No code is necessary.

package sun.scjp;  public enum Color { RED, GREEN, BLUE }  package sun.beta;  // insert code here  public class Beta {  Color g = GREEN;  public static void main( String[] argv)  { System.out.println( GREEN); }  }  The class Beta and the enum Color are in different packages.  Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?()A、 import sun.scjp.Color.*;B、 import static sun.scjp.Color.*;C、 import sun.scjp.Color; import static sun.scjp.Color.*;D、 import sun.scjp.*; import static sun.scjp.Color.*;E、 import sun.scjp.Color; import static sun.scjp.Color.GREEN;

Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A、import utils.*;B、static import utils.*;C、importutils.Repetition.*;D、static importutils.Repetition.*;E、import utils.Repetition.twice();F、import static utils.Repetition.twice;G、static import utils.Repetition.twice;

import java.io.IOException;   public class ExceptionTest(   public static void main (Stringargs)  try (   methodA();   ) catch (IOException e) (   system.out.printIn(“Caught IOException”);  ) catch (Exception e) (   system.out.printIn(“Caught Exception”);   )   )   public void methodA () {   throw new IOException ();  }     What is the result?()  A、 The code will not compile.B、 The output is caught exception.C、 The output is caught IOException.D、 The program executes normally without printing a message.

定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()     A、import utils.*;B、 import utils.Rep.*;C、 import static utils.Rep.twice;D、 static import utils.Rep.twice;

单选题public class ExceptionTest {  class TestException extends Exception {}  public void runTest () throws TestException {}  public void test () /* Point X*/  {  runTest ();  }  }   At point X on line 4, which code can be added to make the code compile?()A Throws Exception.B Catch (Exception e).C Throws RuntimeException.D Catch (TestException e).E No code is necessary.

单选题在J2EE中,有如下代码在Servlet1.java中。  import javax.servlet.*;  import javax.servlet.http.*;  import java.io.IOException;  import java.io.PrintWriter;  public class Servlet1 extends HttpServlet {    public void init()  throws ServletException {   }  public void service(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {      PrintWriter out = response.getWriter();      out.println("hello!");   } }   假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。A编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过B编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”C编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字D编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息

单选题下列Java源程序结构中前三种语句的次序,正确的是(  )。Aimport,package,public classBimport必为首,其他不限Cpublic class,package,importDpackage,import,public class

单选题import java.io.IOException;  public class ExceptionTest(  public static void main (String[]args)  try (  methodA();  ) catch (IOException e)  (  system.out.printIn(“Caught IOException”);  ) catch (Exception e)   (  system.out.printIn(“Caught Exception”);  )  )  public void methodA ()   {  throw new IOException ();  }   What is the result?()A The code will not compile.B The output is caught exception.C The output is caught IOException.D The program executes normally without printing a message.

单选题定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()Aimport utils.*;B import utils.Rep.*;C import static utils.Rep.twice;D static import utils.Rep.twice;

单选题Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()Aimport utils.*;Bstatic import utils.*;Cimportutils.Repetition.*;Dstatic importutils.Repetition.*;Eimport utils.Repetition.twice();Fimport static utils.Repetition.twice;Gstatic import utils.Repetition.twice;

多选题GivenafileGrizzlyBear.java: 1.package animals.mammals; 2. 3.public class GrizzlyBear extends Bear{ 4.voidhunt(){ 5.Salmons=findSalmon(); 6.s.consume(); 7.} 8.} and another file,Salmon.java: 1.packageanimals.fish; 2. 3.public class Salmon extends Fish{ 4.voidconsume(){/*dostuff*/} 5.} Assume both classes are defined in the correct directories for theft packages,and that the Mammal class correctly defines the findSalmon()method.Which two changes allow this code to compile correctly?()Aadd public to the start of line 4 in Salmon.javaBadd public to the start of line 4 in GrizzlyBear.javaCadd import animals.mammals.*;at line 2 in Salmon.javaDadd import animals.fish.*at line 2 in GrizzlyBear.javaEadd import animals.fish.Salmon.*;at line 2 in GrizzlyBear.javaFadd import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java

单选题Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A import utils.*;B static import utils.*;C import utils.Repetition.*;D static import utils.Repetition. *;E import utils.Repetition.twice();F import static utils.Repetition.twice;G static import utils.Repetition.twice;