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: 10388
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.

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: 10388
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.

cristibctr
Posts: 5
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: 10388
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.

MichaelZett
Posts: 21
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: 10388
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.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests