SCJP題庫第239題

 
Given:
1. public class TestOne{
2.   public static void main(String[] args) throws Exception{
3.     Thread.sleep(3000);
4.     System.out.println("sleep");
5.   }
6. }
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The code executes normally and prints "sleep".
D. The code executes normally, but nothing is printed.

Ans: C

解說:第3行呼叫Thread的類別方法sleep,睡眠3秒,之後繼續執行第4行

Comments

Popular posts from this blog

Android-使用webview在V3版的Google地圖GPS定位