2. public class Foo implements Runnable ( 3. public void run (Thread t) { 4. system.out.printIn(“Running.”); 5. } 6. public static void main (String[] args) { 7. new thread (new Foo()).start(); 8. ) 9. ) What is the result?()
A server administrator implements a solution that should fix an issue. Which of the following should the administrator do NEXT in the troubleshooting process?()
Given that Triangle implements Runnable, and: Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads totemporarily pause and allow the other thread to execute?()
public class Score implements Comparable { private int wins, losses; public Score(int w, int 1) { wins = w; losses = 1; } public int getWins() { return wins; } public int getLosses() { return losses; } public String toString() { return “<“ + wins + “,“ + losses + “>”; } // insert code here } Which method will complete this class?()
接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)?
现有: 5. class Order2 implements Runnable { 6. public void run() { 7. for (int x- o; x<4; x++) { 8. try{Thread.sleep(100); )catch (Exception e) { } 9. System.out.print("r"); 10. } } 11. public static void main(string [] args) { 12. Thread t=new Thread(new order2()); 13. t.start(); 14. for(int x=0; x<4; x++) { 15. //insert code here 16. System.out.print("m"); 17. } } } 哪一个插入到第15行,最有可能产生输出 rmrmrmrm?()
接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)?
现有: class Waiting implements Runnable { boolean flag=false; public synchronized void run() { if (flag) { flag=false; System.out.print ("1"); try { this.wait(); ) catch (Exception e) { } System.out.print ("2"); } else { flag=true; System.out.print ("3"); try{Thread.sleep (2000); } catch(Exception e) {} System.out.print ("4"); notify(); } } public static void main (String [] args) { Waiting w=new Waiting(); new Thread (w) .start(); new Thread (w) .start(); } } 以下哪两项是正确的?()
Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实现)interface(接口)?
现有: class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 结果为:()