1.Given the fol ,1.class mythread extends thread {2. 3. public static void main (string [] args) {4. Mythread t = new mythread (); 5. T.Run (); 6.} 7.8. Void Run () {9. FOR (int i = 1; i <3; i) {10. System.out.println (i ".."); 11.} 12.} 13.} What is IS The result? a. this code is not compile due to line 4.b. this code is not compile due to line 5.c. 1..2..d. 1..2..3..3..E. AN EXCEPTION IS thrown at runtime. (c). On the 5th line, the program directly call Run () Method, so although there is no start (), run () is still executed, no compilation error; 2.Which Two of the FOLLOWING METHODS Are Defined in Class THREAD? a. start () b. Wait () c. Notify () d. run () e. Terminate () () E. Terminate () () in the Thread class, only start () and Run () WAIT () and Notify () are methods in java.lang.object, and terminate () completely and thread classes; 3.The Following block of code Creates A Thread Using a runnable target: Runnable target = New runnable (); thread mythread = new thread (target); Which of the folding classes can be used to create the ta rget, so that the preceding code compiles correctly? A. public class MyRunnable extends Runnable {public void run () {}} B. public class MyRunnable extends Object {public void run () {}} C. public class MyRunnable implements Runnable { public void run () {}} D. public class MyRunnable implements Runnable {void run () {}} E. public class MyRunnable implements Runnable {public void start () {}} (c). the interface must implements rather extends, The Run () method must be public, the execution method of the interface is Run () instead of start (); 4.given the folline: 1.class mythread extends thread {2.3. public static void main (String [] args) {4 . Mythread t = new mythread (); 5. T.Start (); 6. System.out.println ("
""); 7. T.Start (); 8. System.out.println ("two."); 9.} 10.11. Public void run () {12. System.out.println ("thread") 14.} 14.} What is the result of this code? A. CompiLATION Fails.b. An Exception Occurs At Runtime. C. Thread One. Thread Two.d. The Output Cannot Be determined. (B). Compilation However, after the Star () method start, I will throw an ILLEGALTHREADSTATEEXCE5.GIVEN THE FOLLOWING: 1.Public class myrunnable imports runnable () {2. Public void run () {3. // some code here4.} 5. Which of these Will Create and start this triead? a. new runnable (MyRunnable) .Start (); b. new thread (); c. new thread (new myrunnable ()). start (); d New myrunnable (). START (); (c). D is incorrect, because there is no start () method in MyRunNable, and only the start () method can start the thread; transfer an instance of a MyRunnable to the constructor At the same time, the thread will start; the name of the class or interface cannot be used for any constructor; 6.given the folline: 1.class mythread extends thread {2.3. Public static void main (String [] args) {4. MythRead T = new mythread (); 5. Thread x = new thread (t); 6. X.Start (); 7.} 8.9. Public void Run () {10. FOR (INT i = 0; i <3; i ) {11. System.out. Println (i ".."); 12.} 13.} 14. .2..3..d. 0..1..2..E. An Exception Occurs at runtime. (D). Thread type IMPLEMENTS RUNNABLE interface, so on the 5th row of objects can be object objects Place in the constructor; 7.given the following .1.class test {2.3. Public static void main (string [] args) {4. Printall (args); 5.} 6.7. Public static void Printall (String [] lines) {8. for (int i = 0; i I ) {9. System.out.println (LINES [I]); 10. thread.currentthread (). Sleep (1000); 11.} 12.} 13} the static method thread.currentthread () Returns a reasonence to the currently executing Thread object.What is the result of this code ?? A. Each String in the array lines will output, with a 1-secnod pause.B. Each String in the array lines will output, with no pause in between because this method is not executed in a Thread.C. Each String in the array lines will output, and there is no guarantee there will be a pause beacuse CurrentThread () may not retrieve this method.D. This code will not compile. (D ) .sleep () method must be attached to the TRY / CATCH block, or the method Printall () must declare it to throw an interruptedException.8.assume you have class what Holds TWO Private variables: a and b.Which of the Following PaiRS CAN Prevent Concurrent Access Problems In That Class? ({Return A B;} public void set (int a, int b) {Return A B;} public void set (int A, int b) {twuid set (int a, int b) {this.a = A; this.b = b;} b. public synchronized int {RETURN A B;} public synchronized void set (int A, int b) {this.a = a; this.b = B;} c. public int} {synchronized (a) {RETURN A B;}} public void set (int a, int b) {synchronized (a) {this.a = a }} d. public int} {reg} {{{{{{{{{{{} public void set (int A) {synchronized (b) {synchronized (b) {synchronized (b) {synchronized (b) {synchronized THIS.A = a; this.b = b;}} e. public synchronized (this) int} {RETURN A B;} public synchronized (this) Void Set (Int A, INT B) ) {THIS.A = a; this.b = b;} F. Public int} {synchronized (this) {RETURN A B;