Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these is the correct declaration of Runnable in java.lang?

  • A.public interface Runnable { void run() throws Exception; }
  • B.public interface Runnable extends Thread { void run(); }
  • C.public interface Runnable { void run(); }
  • D.public abstract class Runnable { public abstract void run(); }

Answer: C

Runnable is an interface with one method that declares no checked exception, which is exactly why run cannot throw one and why Callable was added for tasks that need to. It extends nothing, and Thread implements it rather than the other way round.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.