Java OCA OCP Practice Question 2523

Question

Objects of which of the following can be executed by an Executor?

a  class Main implements Runnable {
       public void run() {}
   }//from w  ww . j av  a 2 s. c o m

b  class Main implements Callable {
       public void call() {}
   }

c  class Main implements Executable {
       public void execute() {}
   }

d  class Main implements Schedulable {
       public void schedule() {}
   }


a

Note

Option (b) is incorrect because the Executor interface defines just one method, void execute(Runnable).

It only accepts objects of Runnable, not Callable.

Options (c) and (d) are incorrect because they use invalid interface names.




PreviousNext

Related