About Question enthuware.ocpjp.v8.2.1342 :

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

Moderator: admin

Post Reply
lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

About Question enthuware.ocpjp.v8.2.1342 :

Post by lenalena »

I answered "javac AssertTest.java" and it marked it wrong???

JPG of screenshot attached...
Attachments
assert.jpg
assert.jpg (37.95 KiB) Viewed 5181 times

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

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

Post by admin »

Your answer seems to have an extra space between javac and AssertTest. Of course, it is correct but the engine is not able match it with the answers specified as correct. It is a limitation of the engine.
Paul.

phusztek
Posts: 6
Joined: Tue Nov 22, 2016 11:04 am
Contact:

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

Post by phusztek »

Hi,
Based on this:
From Java 1.5 onwards, assert is treated as a keyword...
Why this one is correct?
2017-11-20 17_41_51.jpg
2017-11-20 17_41_51.jpg (2.89 KiB) Viewed 4883 times
Thanks!

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

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

Post by admin »

You forgot to read the last part of the explanation that you have quoted, "From Java 1.5 onwards, assert is treated as a keyword by default.
The detailed explanation explains this point further.

Wesley
Posts: 11
Joined: Sun Mar 18, 2018 9:08 pm
Contact:

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

Post by Wesley »

Since it's a class for testing asserts I enabled Asserts and therefore got it wrong. I thought the point of the question was to test enabling asserts. Am I missing something?

I put: javac -ea AssertTest.java

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

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

Post by admin »

Wesley wrote:Since it's a class for testing asserts I enabled Asserts and therefore got it wrong. I thought the point of the question was to test enabling asserts. Am I missing something?

I put: javac -ea AssertTest.java
You need to read the question properly. It is asking about compilation and not execution. -ea flag is applicable only while executing a program and not while compiling it.

Wesley
Posts: 11
Joined: Sun Mar 18, 2018 9:08 pm
Contact:

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

Post by Wesley »

Aaaah my bad. Thanks! That's what I get for always using an IDE.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests