About Question enthuware.ocajp.i.v8.2.1379 :

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

Moderator: admin

Post Reply
haquim
Posts: 1
Joined: Tue May 23, 2017 7:09 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1379 :

Post by haquim »

Since line 2 and 3 have the same option, the compiler will send and error on both lines; not only line 3. So I think the correct options would be
Compilation error because of //1
Compilation error because of //2
Compilation error because of //3

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

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by admin »

Well, the duplicate value occurs at //3 and not at //2. So there will be no error if you fix //1 and //2.

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

bomicbon
Posts: 5
Joined: Sun Jan 21, 2018 7:33 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by bomicbon »

:( error on duplicate case? :( SADBOYZ

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

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by admin »

Yes, that is why option 4 is the correct option.
If you like our products and services, please help us by posting your review here.

cristibctr
Posts: 6
Joined: Sun Jun 18, 2023 11:03 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by cristibctr »

While the answers are valid I think the explanation for the last answer is not quite right. This is not a switch expression but a switch statement since it doesn't return a value.

At least as far as I understand from the jls both a switch expression and a switch statement have the same definition " switch ( Expression ) SwitchBlock " though the former is only allowed when assigning to a variable or using it to return something.

Another way to test if the explanation is right is by assigning the result of the switch in this question to a variable thus getting a compilation error with the message "attempt to break out of a switch expression". So no, you cannot use break in a switch expression.

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

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by admin »

Yes, I see point 3. in the explanation (in 1z0-829 question bank):
3. Observe that this is a valid way to write a switch statement using the new arrow syntax.
Please make sure you are using the most recent version of the question bank.
If you like our products and services, please help us by posting your review here.

cristibctr
Posts: 6
Joined: Sun Jun 18, 2023 11:03 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by cristibctr »

Thanks for your answers on the other topics. I thought I would get a notification in the upper right corner once I posted in a topic (kind of like getting subscribed) so I didn't check every question I had and assumed you hadn't answered yet.

Now onto the current topic. I was referring to the explanation under the 7th answer: "There is no issue with the break statement. It is redundant but allowed within a case block of a switch expression"

A break statement is not allowed within a case block of a switch expression. I tried updating my question bank but apparently I have the most recent version.

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

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by admin »

You are right. It should say "statement". Fixed.
thank you for your feedback!

To get notifications, you will need to subscribe to that topic explicitly. Or, when you come back to the forum, all topics with new responses are highlighted, which you can then check.
If you like our products and services, please help us by posting your review here.

MichaelZett
Posts: 22
Joined: Wed Dec 10, 2014 8:28 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by MichaelZett »

Hi,
in the explanation it reads "2. Adding underscores doesn't actually change the number. The compiler ignores the underscores. So 1_000_000 and 1000000 are actually same and you cannot have two case blocks with the same value. Therefore, the second case at //3 is invalid."

It should be " at //4", correct?

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

Re: About Question enthuware.ocajp.i.v8.2.1379 :

Post by admin »

Yes, for the question 2.3218 in 1z0-829 question bank it should be //4.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 31 guests