Page 1 of 1

About Question enthuware.ocpjp.v7.2.1439 :

Posted: Wed Sep 13, 2017 6:33 am
by horst1a
Answer A shall be right, too.
I have thought Runnable is an interface, so there is no way to call 'new' on it.
Is that different with inner classes ?

Re: About Question enthuware.ocpjp.v7.2.1439 :

Posted: Wed Sep 13, 2017 7:41 am
by admin
Yes, option 1 is indeed a correct option. In this case, you are not instantiating Runnable interface but an anonymous class that implements Runnable interface. So the "new" is not really for Runnable, it is for that anonymous class.

Re: About Question enthuware.ocpjp.v7.2.1439 :

Posted: Sat May 30, 2020 4:18 pm
by saurabh.agarwal560
As the Thread t = new Thread(a) which means 'a' should be Runnable object so how Option C will be correct as it defines a thread object. Please explain.

Re: About Question enthuware.ocpjp.v7.2.1439 :

Posted: Sat May 30, 2020 4:26 pm
by saurabh.agarwal560
Is it that thread class also implements runnable so it is allowed?

Re: About Question enthuware.ocpjp.v7.2.1439 :

Posted: Sun May 31, 2020 1:12 am
by admin
Yes, Thread implements Runnable.