What will be the result of attempting to compile and run the following program?
public class Threader extends Thread { Threader(String name) {/* w w w. ja va 2 s . co m*/ super(name); } public void run() throws IllegalStateException { System.out.println(Thread.currentThread().getName()); throw new IllegalStateException(); } public static void main(String[] args) { new Threader("|T1|").start(); } }
Select the one correct answer.
(c)
Note that the complete signature of the run()
method does not specify a throws clause, meaning it does not throw any checked exceptions.
However, it can always be implemented with a throws clause containing unchecked exceptions, as is the case in the code above.