1. public class a { 2. public void method1() { 3. try { 4. B b=new b(); 5. b.method2(); 6. // more code here 7. } catch (TestException te) { 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class b { 2. public void method2() throws TestException { 3. // more code here 4. } 5. } 1. public class TestException extends Exception { 2. } Given: 31. public void method() { 32. A a=new a(); 33. a.method1(); 34. } Which is true if a TestException is thrown on line 3 of class b?()
第1题:
1. public class Test { 2. public static void main (String args) { 3. unsigned byte b = 0; 4. b--; 5. 6. } 7. } What is the value of b at line 5?()
第2题:
1. public class Exception Test { 2. class TestException extends Exception {} 3. public void runTest() throws TestException {} 4. public void test() /* Point X */ { 5. runTest(); 6. } 7. } At Point X on line 4, which code is necessary to make the code compile?()
第3题:
1. class super { 2. public float getNum() {return 3.0f;} 3. } 4. 5. public class Sub extends Super { 6. 7. } Which method, placed at line 6, will cause a compiler error?()
第4题:
An exception is thrown at runtime.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 4.
Compilation succeeds and no runtime errors with class A occur.
第5题:
InsideOnew ei= eo.new InsideOn();
Eo.InsideOne ei = eo.new InsideOne();
InsideOne ei = EnclosingOne.new InsideOne();
EnclosingOne.InsideOne ei = eo.new InsideOne();
第6题:
Public float getNum() {return 4.0f; }
Public void getNum () { }
Public void getNum (double d) { }
Public double getNum (float d) {retrun 4.0f; }
第7题:
0
1
2
3
第8题:
static class InnerOne { public double methoda() { return d1; } }
static class InnerOne { static double methoda() { return d1; } }
private class InnerOne { public double methoda() { return d1; } }
protected class InnerOne { static double methoda() { return d1; } }
public abstract class InnerOne { public abstract double methoda(); }
第9题:
Change line 2 to: public int a;
Change line 2 to: protected int a;
Change line 13 to: public Sub() { this(5); }
Change line 13 to: public Sub() { super(5); }
Change line 13 to: public Sub() { super(a); }
第10题:
No code is necessary.
throws Exception
catch ( Exception e )
throws RuntimeException
catch ( TestException e)
第11题:
Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. private static void process(byte[] b) { } 4. } 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils?()
第12题:
1. public class OuterClass { 2. private double d1 = 1.0; 3. // insert code here 4. } Which two are valid if inserted at line 3?()
第13题:
1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. } 7. } 8. } What is the result?()
第14题:
doX();
X.doX();
x.X.doX();
x.X myX = new x.X(); myX.doX();
第15题:
process(bytes);
BitUtils.process(bytes);
util.BitUtils.process(bytes);
SomeApp cannot use methods in BitUtils.
import util.BitUtils.*; process(bytes);
第16题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第17题:
Line 33 must be called within a try block.
The exception thrown by method1 in class a is not required to be caught.
The method declared on line 31 must be declared to throw a RuntimeException.
On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.
第18题:
Class A
Compilation fails.
An exception is thrown at line 2.
An exception is thrown at line 6.
The code executes with no output.
第19题:
this.commission = commission;
superb(); commission = commission;
this.commission = commission; superb();
super(name, baseSalary); this.commission = commission;
super(); this.commission = commission;
this.commission = commission; super(name, baseSalary);
第20题:
import utils.*;
static import utils.*;
import utils.Repetition.*;
static import utils.Repetition. *;
import utils.Repetition.twice();
import static utils.Repetition.twice;
static import utils.Repetition.twice;