About Question enthuware.ocpjp.v8.2.1490 :

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

Moderator: admin

Post Reply
schchen2000
Posts: 106
Joined: Mon Mar 28, 2016 11:36 pm
Contact:

About Question enthuware.ocpjp.v8.2.1490 :

Post by schchen2000 »

You want to run Main.class [Assume that it belongs to the default package.] from the command line. It uses two packages good.* and bad.*. You want to disable assertions for all classes of bad.* as well as good.* but at the same time want to enable them for Main.class.
This is my understanding, based on what's in the quote above.

Main.class belongs to the default package means that we DON'T need to include a

package <some_folder>;

as the 1st line in Main.java file.

That's all that is.

"It [Main.class] uses two packages good.* and bad.*."

That means that we have

import good.*;

import bad.*;

inside Main.java file.

So far so good.

"You want to disable assertions for all classes of bad.* as well as good.*"

That means some or all of those classes inside the good or the bad folders contain assert statements in them.

"You want to disable assertions for all classes of bad.* as well as good.* but at the same time want to enable them for Main.class."

That simply means all classes inside the good and the bad folders are disabled as far as the assertions go. At the same time, we want to enable all classes inside those two folders JUST FOR Main.class.

I hope we are on the same page so far. This is what I understood from the above quote on the very top of this post.

To achieve enabling the classes inside the good and the bad folders JUST FOR Main.class, your answer was:

java -ea:... -da:good... -da:bad... Main

-da:good and -da:bad simply tell me that good folder, bad folder, Main.java and Main.class are inside the default package. If not, you would have used something like -da:some_folder.good... and -da:some_folder.bad....

Is that correct?

Having -ea:... enables everything, i.e. enabling Main, everything (sub-folders included) inside both good and bad folders.

Then having -da:good... -da:bad... in that bold command line above EXPLICITLY disables everything (sub-folders included) inside both good and bad folders. In other words, this action "overrides" -ea:....

Therefore, we would end up with everything (sub-folders included) inside both good and bad folders being disabled for Main.

In other words, I'm having a tough time reconciling
You want to disable assertions for all classes of bad.* as well as good.* but at the same time want to enable them for Main.class.
and what your answer choice offers.

What am I missing here? Thanks a lot.

Sorry about the long winded question.

Schmichael

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

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

Post by admin »

Did you read the explanation? It explains exactly what you are asking.
If you like our products and services, please help us by posting your review here.

siyar85
Posts: 1
Joined: Sun Jan 15, 2017 5:19 am
Contact:

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

Post by siyar85 »

Why is option java -ea Main wrong?

By default assertion evaluation is disabled by the JVM and this command enables it only for class "Main".

This would fulfill:
"You want to disable assertions for all classes of bad.* as well as good.* but at the same time want to enable them for Main.class."

Note: the default package can contain more than one class.

If java -ea:... -da:good... -da:bad... Main is the right option, then what about the remaining classes in the default package?
As i said, by default assertions are disabled.
If this "default behaviour by the JVM" is true, then those classes are disabled as in java -ea Main, which turns this answer correct.
If not then java -ea:... -da:good... -da:bad... Main is wrong.

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

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

Post by admin »

1. java -ea Main cannot be correct because Main parameter is the name of the class that java will execute. It is not associated with the flag -ea.
java -ea:Main Main would be valid.

2. The problem statement explicitly mentions all the classes you need to be concerned about i.e. Main class and all classes of good and bad packages. So no need to consider the possibility of default package having more classes.
Even if you consider that possibility, the problem statement doesn't say anyting about whether assertions need to be on or off for thos classes.
If you like our products and services, please help us by posting your review here.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

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

Post by __JJ__ »

Hi admin

Sorry, just to be clear, I can see now why the answer

Code: Select all

java -ea Main 
is incorrect. But if that had been

Code: Select all

java -ea:Main Main 
then would that have satisfied the requirements as stated in the question? I would like to know if I was right in my thinking but wrong in my application of the syntax. Thank you.

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

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

Post by admin »

Yes, java -ea:Main Main would be valid. You should try it out though.
If you like our products and services, please help us by posting your review here.

Bhaskar
Posts: 19
Joined: Fri Aug 02, 2019 7:04 am
Contact:

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

Post by Bhaskar »

You can enable or disable assertions in the unnamed root (default)package (the one in the current directory) using the following commands: java -ea:... myPackage.myProgram
java -da:... myPackage.myProgram
My understanding is that the above code enables and disables assertions for all the classes and sub classes in the default package, which is one per project (i may be wrong on this). I did not understand the bracketed part (the one in the current directory). Which directory is it talking about?

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

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

Post by admin »

Current directory is the directory from which you are running your program. The classpath automatically includes the current directory and you can keep classes that belong to the default package (i.e. classes without a package statement) in the current directory.
If you like our products and services, please help us by posting your review here.

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

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

Post by admin »

Current directory is the directory from which you are running your program. The classpath automatically includes the current directory and you can keep classes that belong to the default package (i.e. classes without a package statement) in the current directory.
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 87 guests