10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()
阅读以下代码: public class Test{ public static void main(){ System.out.println(“x=”+x); } } 请问,代码运行的结果是?()
public class TestOne { public static void main (String[] args) throws Exception { Thread.sleep(3000); System.out.println(”sleep”); } } What is the result?()
现有: public class Pet() public class Cat extends Pet{) 执行代码 Cat c- new Cat(); Pet p= (Pet)c; 后下列哪项是正确的?()
public class Test{ public static void main( String[] argv ){ // insert statement here } } Which statement, inserted at line 3, produces the following output?() Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)
现有: public class Pet() public class Cat extends Pet{) 执行代码 Cat c- new Cat(); Pet p= (Pet)c; 后下列哪项是正确的?()
public class Foo { static int[] a; static { a[0]=2; } public static void main( String[] args) {} } Which exception or error will be thrown when a programmer attempts to run this code?()
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?()
有如下代码:public class Person { … }下列哪个符合该类的构造方法定义
检查下面的代码:class E1 extends Exception{ };class E2 extends E1{ }class SuperQuiz6_2 { }public class Quiz6_3 extends SuperQuiz6_2{public void f(Boolean flag) throws E1{//一一X一一}}下列的语句,哪—个可以放到--X--位置,而且保证编译成功。
读代码:public class Test {public static void main (String args[]) {class Foo {public int i = 3;}Object o = (Object) new Foo();Foo foo = (Foo)o;System.out.println(foo.i);}}结果是:
检查下面的代码: class E1 extends Exception{ } class E2 extends E1 { } public class Quiz6_5{ public static void main(String[] args){ try{ throw new E1(); } // --X-- } } 下列语句,哪一个可以放到--X--位置,而且保证编译成功。
读代码:public class foo {static String s;public static void main (String[]args) {System.out.println (“s=” + s);}}结果是:
class Demo{ public static void main(String[] args){ int x = 0; try{ x = div(1,2); }catch(Exception e){ System.out.println(e); } System.out.println(x) ; } public static int div(int a,int b){ return a / b ; } }
读代码:public class Test {public static void main (String [] args) {String foo = “blue”;String bar = foo;foo = “green”;System.out.println(bar);}}结果是:
(读写文件)下列程序完成了读取指定文件内容的功能,在下划线处应填入的代码是______。import java.io.*; public class test { public static String read (String FileName) throws Exception{ BufferedReader in = new BufferedReader(new FileReader(FileName)); String s = null; StringBuilder sb = new StringBuilder(); While((s=_____.readLine()) != null){ sb.append(s + “n”); } _______.close(); return sb.toString(); } public static void main (String [] args) throws Exception{ System.out.println(read(
代码三: public class Test03 { public static void main(); } }
以下代码可以编译通过 public class Test01 { public static void main(); } }
给定如下代码,下面可以作为该类的构造函数的是()public class Test {}
代码四: public class Test04 { public static void main(); n--; } } }
某 Java源文件代码如下: public class A { int a; } class B { int b; } class C { public static void main()
已知有如下代码: import java.util.*; public class Test{ public static void main(); } }
10、以下程序代码运行时输出的结果是()。public class Foo{ public static void main(String[] args){ try{ System.out.print('A'); foo1(); System.out.print('B'); }catch(RuntimeException e){ System.out.print('C'); }catch(Exception e){ System.out.println('D'); } } public static void foo1() throws RuntimeException{ throw new RuntimeException(); } }
请阅读下面程序 public class ThreadTest { public static void main(String args) throws Exception{int i=0;Hello t=new Hello();while(true) { System.out.println("Good Moming"+i++); if (i==2 && t.isAlive()) {Syste