About Question enthuware.ocajp.i.v8.2.1379 :
Moderator: admin
-
- Posts: 1
- Joined: Tue May 23, 2017 7:09 pm
- Contact:
About Question enthuware.ocajp.i.v8.2.1379 :
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
Compilation error because of //1
Compilation error because of //2
Compilation error because of //3
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 5
- Joined: Sun Jan 21, 2018 7:33 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
error on duplicate case? SADBOYZ
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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.
-
- Posts: 6
- Joined: Sun Jun 18, 2023 11:03 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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.
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.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
Yes, I see point 3. in the explanation (in 1z0-829 question bank):
Please make sure you are using the most recent version of the question bank.3. Observe that this is a valid way to write a switch statement using the new arrow syntax.
If you like our products and services, please help us by posting your review here.
-
- Posts: 6
- Joined: Sun Jun 18, 2023 11:03 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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.
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.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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.
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.
-
- Posts: 22
- Joined: Wed Dec 10, 2014 8:28 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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?
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?
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :
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.
Who is online
Users browsing this forum: Google [Bot] and 31 guests