【正文】
x。 d) wrap the code inside the foo() method with a synchronized( this ) block e) wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here } 66) 11. Runnable r = new Runnable() { public void run() { (Cat)。 }}。 Thread t = new Thread(r) { public void run() { (Dog)。 } }。 ()。 程序運(yùn)行結(jié)果是( ) a) Cat b) Dog c) Compilation fails. d) The code runs with no output. 67) 1. public class Threads5 { public static void main (String[] args) { new Thread(new Runnable() { public void run() { (bar)。 }}).start()。 } 8. }程序運(yùn) 行結(jié)果是( ) a) Compilation fails. b) An exception is thrown at runtime. c) The code executes normally and prints bar. d) The code executes normally, but nothing prints. 68) 10. class One { void foo() { } . } class Two extends One { //insert method here }下列哪個(gè)方法放到第 14 行,程序可以編譯正常,請(qǐng)選擇 3 個(gè)( ) a) nt foo() { /* more code here */ } b) void foo() { /* more code here */ } c) public void foo() { /* more code here */ } d) private void foo() { /* more code here */ } e) protected void foo() { /* more code here */ } 69) 10. abstract public class Employee { protected abstract double getSalesAmount()。 public double getCommision() { return getSalesAmount() * 。 } 15. } class Sales extends Employee { // insert method here }下列哪個(gè)方法放到第 17 行,程序可以編譯正常,請(qǐng)選擇 2 個(gè)( ) a) double getSalesAmount() { return 。 } b) public double getSalesAmount() { return 。 } c) private double getSalesAmount() { return 。 } d) protected double getSalesAmount() { return 。 } 70) 1. class X { X() { (1)。 } X(int x) { this()。 (2)。 } 6. } public class Y extends X { Y() { super(6)。 (3)。 } Y(int y) { this()。 (4)。 11. } . public static void main(String[] a) { new Y(5)。 } }程序運(yùn)行結(jié)果是( ) a) 13 b) 134 c) 1234 d) 2134 e) 2143 f) 4321 71) 10. package 。 public class Geodetics { . public static final double DIAMETER = 。 // kilometers }哪兩行代碼可以正確的訪問變量 DIAMETER,選擇 2 個(gè)( ) a) import 。 public class TerraCarta { public double halfway() { return 。 } b) import static 。 public class TerraCarta{ public double halfway() { return DIAMETER/。 } } c) import static .*。 public class TerraCarta { public double halfway() { return DIAMETER/。 } } d) package 。 public class TerraCarta { public double halfway() { return DIAMETER/。 } } 72) 1. public class A { public void doit() { } public String doit() { return a。 } public double doit(int x) { return 。 } 10. }運(yùn)行結(jié)果是( ) a) An exception is thrown at runtime. b) Compilation fails because of an error in line 7. c) Compilation fails because of an error in line 4. d) Compilation succeeds and no runtime errors with class A occur. 73) 35. String name = Jane Doe。 int $age = 24。 Double _height = 。 double ~temp = 。 哪行代碼是正確的,選擇 2 個(gè)( ) a) 35 b) 36 c) 37 d) 38 74) 10. interface Foo { int bar()。 } public class Sprite { public int fubar( Foo foo ) { return ()。 } public void testFoo() { fubar( // insert code here )。 } 16. }下邊哪行代碼是正確的( ) a) Foo { public int bar() { return 1。 } b) new Foo { public int bar() { return 1。 } c) new Foo() { public int bar() { return 1。 } d) new class Foo { public int bar() { return 1。 } 75) 11. public enum Title { MR(Mr.), MRS(Mrs.), MS(Ms.)。 private final String title。 private Title(String t) { title = t。 } public String format(String last, String first) { return title + + first + + last。 17. } 18. } public static void main(String[] args) { ((Doe, John))。 21. } 運(yùn)行結(jié)果是( ) a) Mr. John Doe b) An exception is thrown at runtime. c) Compilation fails because of an error in line 12 d) Compilation fails because of an error in line 15. 76) 10. class Line { public static class Point {} } class Triangle { // insert code here }要?jiǎng)?chuàng)建一個(gè) point 的對(duì)象,下面那句是正確的( ) a) Point p = new Point()。 b) p = new ()。 c) The Point class cannot be instatiated at line 15. d) Line l = new Line() 。 p = new ()。 77) 接口里的變量默認(rèn)是什么類型的,選擇 3 個(gè)( ) a) final b) static c) private d) public e) protected f) native 78) 1. package util。 public class BitUtils { public static void process(byte[] b) { /* more code here */ } } package app。 . public class SomeApp { public static void main(String[] args) { byte[] bytes = new byte[256]。 // insert code here } 7. }在第五行調(diào)用 process 方法,下邊哪句代碼是正確的( ) a) process(bytes)。 b) (bytes)。 c) (bytes)。 d) import .*。 process(bytes)。 79) class Inner { private int x。 public void setX(int x){ = x。 } public int getX(){ return x。 } } class Outer{ private Inner y。 public void setY(Inner y){ = y。 } public Inner getY(){ return y。 } } public class Gamma{ public static void main(String[] args){ Outer o = new Outer()。 Inner i = new Inner()。 int n = 10。 (n)。 (i)。 //insert code here (().getX())。 } }下邊哪行代碼放到注釋的地方,可以保證程序輸出結(jié)果為 100,選擇 3 個(gè)( ) a) n = 100。 b) ( 100 )。 c) ().setX( 100 )。 d) i = new Inner()。 ( 100 )。 e) ( i )。 i = new Inner()。 ( 100 )。 f) i = new Inner()。 ( 100 )。 ( i )。 80) 11. class Snoochy { Boochy booch。 public Snoochy() { booch = new Boochy(this)。 } } class Boochy { Snoochy snooch。 public Boochy(Snoochy s) { snooch = s。 } } And the statements: public static void main(String[] args) { Snoochy snoog = new Snoochy()。 snoog = null。 .// more code here }23 行執(zhí)行完之后,下邊哪句話是正確的( ) a) None of these objects are eligible for garbage collection. b) Only the object referenced by booch is eligible for garbage collection. c) Only the object referenced by snooch is eligible for garbage c