• 2021-04-14 问题

    (9-2)下面程序能够通过编译检查。 public class Demo5 { public static void main(String[] args) { try { System.out.println(3/0); System.out.println("你好"); }catch(Exception e) { e.printStackTrace(); }catch(ArithmeticException e) { e.printStackTrace(); } } }

    (9-2)下面程序能够通过编译检查。 public class Demo5 { public static void main(String[] args) { try { System.out.println(3/0); System.out.println("你好"); }catch(Exception e) { e.printStackTrace(); }catch(ArithmeticException e) { e.printStackTrace(); } } }

  • 2021-04-14 问题

    Throwable类中的printStackTrace ()方法用于将此throwable及其追踪输出至标准错误流。

    Throwable类中的printStackTrace ()方法用于将此throwable及其追踪输出至标准错误流。

  • 2022-06-08 问题

    Throwable类中的printStackTrace(PrintStream s)方法用于将此throwable及其追踪输出至标准错误流。( )

    Throwable类中的printStackTrace(PrintStream s)方法用于将此throwable及其追踪输出至标准错误流。( )

  • 2021-04-14 问题

    (9-4)请根据提示补全程序空白处,使程序能够正确运行。 public class Demo { static void show() throws ① { System.out.println("抛出异常!"); throw new IllegalAccessException("一个异常"); } public static void main(String []args) { try { show(); }catch( ② e ) { e.printStackTrace(); } } }

    (9-4)请根据提示补全程序空白处,使程序能够正确运行。 public class Demo { static void show() throws ① { System.out.println("抛出异常!"); throw new IllegalAccessException("一个异常"); } public static void main(String []args) { try { show(); }catch( ② e ) { e.printStackTrace(); } } }

  • 2021-04-14 问题

    class MyException extends (1) { } public class Demo { public static void main(String[] args) { try { show(); } catch ( (2) e) { e.printStackTrace(); } } public static void show() (3) MyException { throw new MyException(); } 以上程序,创建了一个自定义异常(编译异常),请补全空白处代码

    class MyException extends (1) { } public class Demo { public static void main(String[] args) { try { show(); } catch ( (2) e) { e.printStackTrace(); } } public static void show() (3) MyException { throw new MyException(); } 以上程序,创建了一个自定义异常(编译异常),请补全空白处代码

  • 2022-06-08 问题

    在下列程序的下划线处,填入适当语句使程序能正确执行并输出异常栈信息。 public class ThrowableException{ public static void main(String args[]{ try{ throw new Throwable(“这里是本人定义的异常”); }catch(Throwable e){ System.out.println("Caught Throwable"); System.out.println("e.getMessage(): "+e.getMessage()); System.out.println("e.toString():"+e.toString()); System.out.println( "e.printStackTrace():"); 【 】;}}}

    在下列程序的下划线处,填入适当语句使程序能正确执行并输出异常栈信息。 public class ThrowableException{ public static void main(String args[]{ try{ throw new Throwable(“这里是本人定义的异常”); }catch(Throwable e){ System.out.println("Caught Throwable"); System.out.println("e.getMessage(): "+e.getMessage()); System.out.println("e.toString():"+e.toString()); System.out.println( "e.printStackTrace():"); 【 】;}}}

  • 2022-06-08 问题

    分析如下Java代码,有标注的四行代码中,有错误的是第( )处? A: port java.io.FileWriter; B: port java.io.IOException; C: blic class Test { D: blic static void main(String[ ] args) { E: ring str = "Hello World"; F: leWriter fw = null; G: y { H: = new FileWriter("c:\\hello.txt"); // 1 I: .write(str); // 2 J: catch (IOException e) { K: printStackTrace(); // 3 L: finally {

    分析如下Java代码,有标注的四行代码中,有错误的是第( )处? A: port java.io.FileWriter; B: port java.io.IOException; C: blic class Test { D: blic static void main(String[ ] args) { E: ring str = "Hello World"; F: leWriter fw = null; G: y { H: = new FileWriter("c:\\hello.txt"); // 1 I: .write(str); // 2 J: catch (IOException e) { K: printStackTrace(); // 3 L: finally {

  • 2022-05-29 问题

    从对象流中读取对象,请在下面横线处填写代码完成此程序。 import java.util. *; import java. io. *; public class UnSerializeDate { date d = null; UnSerializeDate ( ) { try { FileInputStream f1 = new FileInputStream("date.ser"); d = (Date) s. readobject (); f1,close(); } catch (Exceptin e) { e. printStackTrace (); } } public static main(String args [] ) { System.out.println("The date read is: "+ a.d.toString()); } }

    从对象流中读取对象,请在下面横线处填写代码完成此程序。 import java.util. *; import java. io. *; public class UnSerializeDate { date d = null; UnSerializeDate ( ) { try { FileInputStream f1 = new FileInputStream("date.ser"); d = (Date) s. readobject (); f1,close(); } catch (Exceptin e) { e. printStackTrace (); } } public static main(String args [] ) { System.out.println("The date read is: "+ a.d.toString()); } }

  • 2022-06-08 问题

    下列程序运行后的结果可能是________。import java. io. *;public class Test { public static void main (String [] args) { File file =new File ( "hello . txt" ) ; if (file. exists () ) { file.delete () ; } else { try { file . createNewFile ( ) ; } catch (Exception e ) { e .printStackTrace ( ) ; } } }} A: 如果文件不存在 ,则程序退出 B: 如果文件已经存在 , 则程序退出 C: 如果文件已经存在,则保留该文件 D: 如果文件不存在 , 则创建该文件

    下列程序运行后的结果可能是________。import java. io. *;public class Test { public static void main (String [] args) { File file =new File ( "hello . txt" ) ; if (file. exists () ) { file.delete () ; } else { try { file . createNewFile ( ) ; } catch (Exception e ) { e .printStackTrace ( ) ; } } }} A: 如果文件不存在 ,则程序退出 B: 如果文件已经存在 , 则程序退出 C: 如果文件已经存在,则保留该文件 D: 如果文件不存在 , 则创建该文件

  • 2022-06-05 问题

    5.1 在(1)~(3)处填上适当的语句,使程序能正常运行。 class MyThread implements Runable { (1) { while(true){System.out.print("hello"); try { (2) //休眠1秒钟 } catch (InterruptedException e) { e.printStackTrace(); } }}} public class Demo{ public static void main(String []s){ MyThread thread1= (3) //声明创建对象thread1 Thread thread = new Thread(thread1,"线程1") thread.start(); //通过对象thread启动线程 }}

    5.1 在(1)~(3)处填上适当的语句,使程序能正常运行。 class MyThread implements Runable { (1) { while(true){System.out.print("hello"); try { (2) //休眠1秒钟 } catch (InterruptedException e) { e.printStackTrace(); } }}} public class Demo{ public static void main(String []s){ MyThread thread1= (3) //声明创建对象thread1 Thread thread = new Thread(thread1,"线程1") thread.start(); //通过对象thread启动线程 }}

  • 1 2 3 4 5 6 7 8 9 10