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: 10388
- 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.
-
- Posts: 5
- Joined: Sun Jan 21, 2018 7:33 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1379 :


-
- Site Admin
- Posts: 10388
- 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.
-
- Posts: 5
- 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: 10388
- 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.
-
- Posts: 21
- 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: 10388
- 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.
Who is online
Users browsing this forum: No registered users and 8 guests