About Question enthuware.ocpjp.v8.2.1382 :

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

Moderator: admin

Post Reply
mrmuiz
Posts: 49
Joined: Mon Jul 27, 2015 4:34 am
Contact:

About Question enthuware.ocpjp.v8.2.1382 :

Post by mrmuiz »

This question showed up in the "Advanced Class Design", shouldn't it be under "Threads" section?

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

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by admin »

It could be considered to be belonging to Threads topic because of the reference to Thread class but it has been put in Nested classes topic because it involves instantiating and using a nested class. It does not present any threading related issues either.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

RAZER-KIEV
Posts: 17
Joined: Thu Oct 01, 2015 4:06 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by RAZER-KIEV »

Does an invocation of psvm method by JVM not creates new Thread object?

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

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by admin »

Yes, but from the certification perspective, we are concerned only with the threads created by our code.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

RAZER-KIEV
Posts: 17
Joined: Thu Oct 01, 2015 4:06 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by RAZER-KIEV »

So, I think that question "How many Thread objects are created BY THE ABOVE PROGRAM when it is compiled and run?" looks like ambiguously if we have 3 Threads generated by JVM.

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

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by admin »

It is not ambiguous. The program that is given in the question creates only 2 threads.
Considering threads created by JVM doesn't make any sense here. It may create many threads. For example, it will create one for GC as well. If you take a thread dump of this java program, you may see 8-9 or more threads created.
If you like our products and services, please help us by posting your review here.

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

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by horst1a »

I am puzzled by the explanation. It says, TestClass is also a thread, because it extends Thread.
If it did not extend Thread, wouldn't we have 2 threads,nevertheless, because the main-method of TestClass is
creating its own thread ?

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

Re: About Question enthuware.ocpjp.v8.2.1382 :

Post by admin »

The question is asking about the number of Thread objects that are created by the given code. It is not asking about number of "threads" created (irrespective of whether by program or the jvm).

Creation of a Thread object and "creating a thread" are two different things. A thread (with small t) is created by the JVM when you call start on a Thread object. Having a Thread object doesn't necessarily mean there is a thread of execution.
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 34 guests