Virtual threads are instances of java.lang.VirtualThread class. VirtualThread extends BaseVirtualThread, which in turn extends Thread. Although VirtualThread is-a Thread, it is not correct to say that a virtual thread is an instance of the Thread class.
I don't get it. C extends B, B extends A, and you are saying here that C is not instance of A? will the instanceof operator fail to identify VirtualThread as Thread?
About Question enthuware.ocpjp.v21.2.4025 :
Moderator: admin
-
- Posts: 16
- Joined: Sat Nov 30, 2024 5:27 am
- Contact:
About Question enthuware.ocpjp.v21.2.4025 :
Last edited by dameest on Sun Dec 22, 2024 11:09 am, edited 1 time in total.
-
- Site Admin
- Posts: 10383
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4025 :
No, that is not what it is saying.
VirtualThread is-a Thread <--- Correct because VirtualThread does extend indirectly from Thread
VirtualThread is an instance of the Thread class <-- Not correct because you don't do new Thread() to create a VirtualThread
new Thread() <---- This creates an instance of the Thread class
new VirtualThread() <---- This would theoretically create an instance of a VirtualThread class but of course there is no such constructor so this is wrong.
VirtualThread is-a Thread <--- Correct because VirtualThread does extend indirectly from Thread
VirtualThread is an instance of the Thread class <-- Not correct because you don't do new Thread() to create a VirtualThread
new Thread() <---- This creates an instance of the Thread class
new VirtualThread() <---- This would theoretically create an instance of a VirtualThread class but of course there is no such constructor so this is wrong.
-
- Posts: 16
- Joined: Sat Nov 30, 2024 5:27 am
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4025 :
Well, that's definitely a tricky one...
-
- Site Admin
- Posts: 10383
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v21.2.4025 :
Yes, I agree. unfortunately as the comment under the option notes, a similar ambiguous statement was seen in the real exam. We just want to make sure that the candidate is aware of the situation.
Who is online
Users browsing this forum: Bing [Bot] and 9 guests