class MyApp{ public static void main(String[] args){ int age; System.out.println(“age=”+age); } } 執(zhí)行上述代碼后輸出的結(jié)果是哪項(xiàng)?()
A.age=0 B.age=null C.age= D.程序編譯錯(cuò)誤
class Beta { public static void main(String [] args) { Integer x = new Integer(6) * 7; if (x != 42) { System.out.print("42 "); } else if (x.equals(42)) { System.out.print("dot = "); } else { System.out.print("done"); } } } 結(jié)果為:()
A.42 B.done C.dot = D.編譯失敗
class Account { private int balance; public void setBalance(int b) { balance = b; } public int getBalance() { return balance; } public void clearBalance() { balance = 0; } } 哪一個(gè)改變可以使 Account 類線程安全?()
A.在第2行加 synchronized 修飾符。 B.在第3行加 synchronized 修飾符。 C.在第3行、第4行和第6行加 synchronized 修飾符。 D.在第4行、第6行和第8行加 synchronized 修飾符。