public class Pet{} public class Cat extends Pet{} 執(zhí)行代碼 Cat c = new Cat(); Pet p = (Pet)c; 下列哪項(xiàng)是正確的?
A.Pet p = (Pet)c正常執(zhí)行 B.Pet p = (Pet)c編譯錯誤 C.Pet p = (Pet)c運(yùn)行錯誤 D.以上都不對
class Foo { public static void main(String [] args) { int x = 0; int y = 4; for(int z=0; z 〈 3; z++, x++) { if(x 〉 1 & ++y 〈 10) y++; } System.out.println(y); } } 結(jié)果是什么?()
A.6 B.7 C.8 D.10
5. class Order2 implements Runnable { 6. public void run() { 7. for(int x = 0; 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行,最有可能產(chǎn)生輸出 rmrmrmrm ?()
A.Thread.sleep(1); B.Thread.sleep(100); C.Thread.sleep(1000); D.try { Thread.sleep(100); } catch (Exception e) { }