About Question enthuware.ocpjp.v7.2.1439 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
horst1a
Posts: 37
Joined: Mon Jun 12, 2017 2:16 am
Contact:

About Question enthuware.ocpjp.v7.2.1439 :

Post 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 ?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

saurabh.agarwal560
Posts: 11
Joined: Thu May 28, 2020 9:53 am
Contact:

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

Post 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.

saurabh.agarwal560
Posts: 11
Joined: Thu May 28, 2020 9:53 am
Contact:

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

Post by saurabh.agarwal560 »

Is it that thread class also implements runnable so it is allowed?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Yes, Thread implements Runnable.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests