单项选择题
class MyThread extends Thread {
public void run() { System.out.println(“AAA”); }
public void run(Runnable r) { System.out.println(“BBB”); }
public static void main(String[] args) {
new Thread(new MyThread()).start();
}
}
What is the result?()
A. AAA
B. BBB
C. Compilation fails.
D. The code runs with no output.
相关考题
-
单项选择题
WhathappenswhenthreadXexecutesawait()methodonobjectA,withoutowningobjectA’slock?()
A. Compilation fails.
B. An exception is thrown.
C. The wait() method has no effect.
D. Thread X receives the lock immediately.
E. Object A moves the thread to the wait pool. -
单项选择题
public class SyncTest { private int x; private int y; private synchronized void setX( int i ) { x = i; } private synchronized void setY( int i ) { y = i; } public void setXY( int i ) { setX(i); setY(i); } public synchronized boolean check() { return x != y; } } Under which condition will check return true when called from a different class? ()
A. check can never return true.
B. check can return true when setXY is called by multiple threads.
C. check can return true when multiple threads call setX and setY separately.
D. check can return true only if SyncTest is changed to allow x and y to be set separately. -
单项选择题
package foo; public class Outer { public static class Inner { } } Which statement is true?()
A. Compilation fails.
B. An instance of the Inner class can be constructed with “new Outer.Inner()”.
C. An instance of the Inner class cannot be constructed outside of package foo.
D. An instance of the Inner class can be constructed only from within the Outer class.
E. From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.
