11. public class Commander { 12. public static void main(String[] args) { 13. String myProp = /* insert code here */ 14. System.out.println(myProp); 15. } 16. } and the command line: java -Dprop.custom=gobstopper Commander Which two, placed on line 13, will produce the output gobstopper?()
第1题:
public class SomeException { } Class a: public class a { public void doSomething() { } } Class b: public class b extends a { public void doSomething() throws SomeException { } } Which is true about the two classes?()
第2题:
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?()
第3题:
interface Data { public void load(); } abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class?()
第4题:
10. abstract public class Employee { 11. protected abstract double getSalesAmount(); 12. public double getCommision() { 13. return getSalesAmount() * 0.15; 14. } 15. } 16. class Sales extends Employee { 17. // insert method here 18. } Which two methods, inserted independently at line 17, correctly complete the Sales class?()
第5题:
Which two demonstrate an “is a” relationship?()
第6题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第7题:
peep
bark
meow
Compilation fails.
An exception is thrown at runtime.
第8题:
public class Employee extends Info implements Data { public void load() { /*do something*/ } }
public class Employee implements Info extends Data { public void load() { /*do something*/ } }
public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
第9题:
Compilation of both classes will fail.
Compilation of both classes will succeed.
Compilation of class a will fail. Compilation of class b will succeed.
Compilation of class a will fail. Compilation of class a will succeed.
第10题:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
第11题:
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); }
第12题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第13题:
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?()
第14题:
Which three demonstrate an “is a” relationship?()
第15题:
Which two allow the class Thing to be instantiated using new Thing()?
第16题:
Which the two demonstrate an “is a” relationship?()
第17题:
What produces a compiler error?()
第18题:
10. class Line { 11. public class Point { public int x,y; } 12. public Point getPoint() { return new Point(); } 13. } 14. class Triangle { 15. public Triangle() { 16. // insert code here 17. } 18. } Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()
第19题:
Foo { public int bar() { return 1; } }
new Foo { public int bar() { return 1; } }
newFoo() { public int bar(){return 1; } }
new class Foo { public int bar() { return 1; } }
第20题:
public class X { } public class Y extends X { }
public interface Shape { } public interface Rectangle extends Shape{ }
public interface Color { } public class Shape { private Color color; }
public interface Species { } public class Animal { private Species species; }
public class Person { } public class Employee { public Employee(Person person) { }
interface Component { } class Container implements Component { private Component[] children; }
第21题:
public class Thing { }
public class Thing { public Thing() {} }
public class Thing { public Thing(void) {} }
public class Thing { public Thing(String s) {} }
public class Thing { public void Thing() {} public Thing(String s) {} }
第22题:
StackOverflowError
NullPointerException
NumberFormatException
IllegalArgumentException
ExceptionlnlnitializerError
第23题:
class A { public A(int x) {} }
class A {} class B extends A { B() {} }
class A { A() {} } class B { public B() {} }
class Z { public Z(int) {} } class A extends Z {}
第24题:
Direction d = NORTH;
Nav.Direction d = NORTH;
Direction d = Direction.NORTH;
Nav.Direction d = Nav.Direction.NORTH;