Page 1 of 1

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

Posted: Tue May 23, 2017 7:13 pm
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

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

Posted: Tue May 23, 2017 8:11 pm
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.

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

Posted: Fri Jan 26, 2018 8:01 am
by bomicbon
:( error on duplicate case? :( SADBOYZ

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

Posted: Fri Jan 26, 2018 10:19 pm
by admin
Yes, that is why option 4 is the correct option.

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

Posted: Fri Jul 14, 2023 8:51 am
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.

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

Posted: Fri Jul 14, 2023 9:59 am
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.

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

Posted: Sat Jul 15, 2023 4:17 am
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.

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

Posted: Mon Jul 17, 2023 12:02 am
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.

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

Posted: Mon Jul 17, 2023 4:19 am
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?

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

Posted: Mon Jul 17, 2023 5:31 am
by admin
Yes, for the question 2.3218 in 1z0-829 question bank it should be //4.