Given the following code, which set of code can be used to replace the comment so that the program displays time to the console every second?
import java.applet.*;
import java.util.*;
public class Test extends Applet implements Runnable {
public void init() {
| Thread t = new Thread(this); |
}
public void run() {
| //display time every second |
| System.out.println(new Date().toString()); |
}
}
◦ try { sleep(1000); } catch(InterruptedException e) { }
◦ try { Thread.sleep(1000); } catch(RuntimeException e) { }
◦ try { t.sleep(1000); } catch(InterruptedException e) { }
◦ try { Thread.sleep(1000); } catch(InterruptedException e) { }