查题网
高校
河南理工大学
截止11-14,该科目累计收录道题目。
返回课程列表
19[分析题] class Ex extends Exception {} public class AlwaysFinally { public static void main(String[] args) { System.out.println( "Entering first try block"); try { System.out.println( "Entering second try block"); try { throw new Ex(); } finally { System.out.println( "finally in 2nd try block"); } } catch(Ex e) { System.out.println( "Caught Ex in first try block"); } finally { System.out.println( "finally in 1st try block"); } } } 上述代码执行后的结果是?
查看答案
2022-01-08 01:56:19
20[分析题] public class FinallyWorks { static int count = 0; public static void main(String[] args) { while(true) { try { // post-increment is zero first time: if(count == 0) throw new Exception(); System.out.println("No exception"); } catch(Exception e) { System.out.println("Exception thrown"); } finally { System.out.println("in finally clause"); if(count == 2) break; // out of "while" } } } }
查看答案
2022-01-08 01:56:19
15[分析题] 分析下面程序,写出程序执行结果; public class Testp { public static void test(boolean test) { test = ! test; System.out.println("In test(boolean) : test = " test); } public static void main(String[] args) { boolean test = true; System.out.println("Before test(boolean) : test = " test); test(test); System.out.println("After test(boolean) : test = " test); } }
查看答案
2022-01-08 01:55:19
16[分析题] class Ex0707Super { public Ex0707Super(String name) { System.out.println("superclass constructor" name); } } class Ex0707Sub extends Ex0707Super { public Ex0707Sub(String name) { System.out.println("subclass constructor" name); } public Ex0707Sub() { System.out.println("subclass constructor no name"); super("no name"); } } public class Ex0707Demo { Ex0707Super superObj=new Ex0707Super("zhangsan"); Ex0707Sub subObj = new Ex0707Sub("lisi"); Ex0707Super superRef=subObj; Ex0707Sub subRef=superObj; } 上述程序存在3个错误,请指出来,并写出修改方案。
查看答案
2022-01-08 01:55:19
17[分析题] public class Ex0708Class { private int method(int value) { System.out.println("private method(int)" value); return value; } public String method(int value) { System.out.println("method(int)" value); return "value" value; } public static int method(int value) { System.out.println("method(int)" value); return value; } public final int method(int value) { System.out.println("method(int)" value); return value; } } 上述代码存在3个错误,请找出来?
查看答案
2022-01-08 01:55:19
12[分析题] 下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 public class AmIWrong implements Runnable { Thread mt=Thread(this); mt.start(); void run() { System.out.println(“I am alive now”); } }
查看答案
2022-01-08 01:54:19
13[分析题] 查看下面程序,指出它的语法错误: import java.io.*; package myPackage; public class One { public void display(){ System.out.println(“aa”); } } public class Two { Public void display() { System.out.println(“bbb”); } }
查看答案
2022-01-08 01:54:19
14[分析题] public class Test { public static void main(String[] args) { int val; StringBuffer sb1,sb2; val=10; sb1=new StringBuffer("apples"); sb2=new StringBuffer("pears"); System.out.println("val=" val); System.out.println("sb1=" sb1); System.out.println("sb2=" sb2); System.out.println(""); System.out.println("calling modify"); modify(val,sb1,sb2); System.out.println("return from modify"); System.out.println(""); System.out.println("val=" val); System.out.println("sb1=" sb1); System.out.println("sb2=" sb2); } public static void modify(int a,StringBuffer r1,StringBuffer r2) { System.out.println("in modify...."); a=0; r1=null; r2.append("taste good"); System.out.println("val=" a); System.out.println("sb1=" r1); System.out.println("sb2=" r2); } } 上述代码执行后的结果是?
查看答案
2022-01-08 01:54:19
9[分析题] 下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 class AmIWrong { int data1,data2; AmIWrong() { data1=-1; } AmIWrong(int d) { data2=d; this(); } }
查看答案
2022-01-08 01:53:19
10[分析题] 下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 interface MyInterface { void method1(); } abstract class Parent implements MyInterface { } class Child extends Parent { void method1() { System.out.println(“I am implemented now!”); } }
查看答案
2022-01-08 01:53:19
首页
上一页
...
579
580
581
(current)
582
583
...
下一页
尾页