网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
public class TestSeven extends Thread {  private static int x;  public synchronized void doThings() {  int current = x;  current++;  x = current;  }  public void run() {  doThings();  }  }  Which is true?()
A

 Compilation fails.

B

 An exception is thrown at runtime.

C

 Synchronizing the run() method would make the class thread-safe.

D

 The data in variable “x” are protected from concurrent access problems.

E

 Declaring the doThings() method as static would make the class thread-safe.

F

 Wrapping the statements within doThings() in a synchronized(new Object()) {} block would make the class thread-safe.


参考答案

参考解析
解析: 暂无解析
更多 “单选题public class TestSeven extends Thread {  private static int x;  public synchronized void doThings() {  int current = x;  current++;  x = current;  }  public void run() {  doThings();  }  }  Which is true?()A  Compilation fails.B  An exception is thrown at runtime.C  Synchronizing the run() method would make the class thread-safe.D  The data in variable “x” are protected from concurrent access problems.E  Declaring the doThings() method as static would make the class thread-safe.F  Wrapping the statements within doThings() in a synchronized(new Object()) {} block would make the class thread-safe.” 相关考题
考题 单选题Which type of event indicates a key pressed on a java.awt.Component?()A  KeyEventB  KeyDownEventC  KeyPressEventD  KeyTypedEventE  KeyPressedEvent

考题 单选题public class Person {  private name;  public Person(String name) {  this.name = name;  }  public boolean equals(Object o) {  if( !o instanceof Person ) return false;  Person p = (Person) o;  return p.name.equals(this.name);  }  }  Which is true?()A  Compilation fails because the hashCode method is not overridden.B  A HashSet could contain multiple Person objects with the same name.C  All Person objects will have the same hash code because the hashCode method is not overridden.D  If a HashSet contains more than one Person object with name=”Fred”, then removing another person, also with name=”Fred”, will remove them all.

考题 单选题public static void main(String[] args) {  try {  args=null;  args[0] = “test”;  System.out.println(args[0]);  } catch (Exception ex) {  System.out.println(”Exception”);  } catch (NullPointerException npe) {  System.out.println(”NullPointerException”);  }  }  What is the result?()A  testB  ExceptionC  Compilation fails.D  NullPointerException

考题 单选题int x = 1, y =6;  while (y--) {  x++;  }  System.out.println(“x =” + x + “y =” +y); What is the result?()A  x = 6 y = 0B  x = 7 y = 0C  x = 6 y = -1D  x = 7 y = -1E  Compilation fails.

考题 单选题What will be the result of attempting to run the following program?()   public class Qaa75 {   public static void main(String args[]) {   String[][][] arr = {   { {}, null },   { { "1", "2" }, { "1", null, "3" } },   {},   { { "1", null } }  };   System.out.println(arr.length + arr[1][2].length);   }   }A The program will terminate with an ArrayIndexOutOfBoundsException.B The program will terminate with a NullPointerException.C 4 will be written to standard output.D 6 will be written to standard output.E 7 will be written to standard output.

考题 单选题public class Yikes {  public static void go(Long n) {System.out.println(”Long “);}  public static void go(Short n) {System.out.println(”Short “);}  public static void go(int n) {System.out.println(”int “);}  public static void main(String [] args) {  short y= 6;  long z= 7;  go(y);  go(z);  }  }  What is the result?()A  int LongB  Short LongC  Compilation fails.D  An exception is thrown at runtime.

考题 单选题class Super {  public Integer getLenght() { return new Integer(4); } }  public class Sub extends Super {  public Long GetLenght() { return new Long(5); }  public static void main(String[] args) { Super sooper = new Super();  Sub sub = new Sub();  System.out.println(  sooper.getLenght().toString() + “,” +  sub.getLenght().toString() ); } }  What is the output?()A  4,4B  4,5C  5,4D  5,5E  Compilation fails.

考题 多选题Which two code fragments are most likely to cause a StackOverflowError?()AABBCCDDEEFF