Page 1 of 1

About Question enthuware.ocpjp.v17.2.3683 :

Posted: Sat Jul 16, 2022 1:31 pm
by elotmanik
I think the response is not fully correct, some options are though correct. example Option1 is correct, you can declare a sealed class without permits if classes which extend it are in the same java file as the sealed class

Re: About Question enthuware.ocpjp.v17.2.3683 :

Posted: Sun Jul 17, 2022 4:52 am
by admin
You are right. This has now been fixed and an explanation has been added..
thank you for your feedback!

Re: About Question enthuware.ocpjp.v17.2.3683 :

Posted: Wed Jul 20, 2022 5:31 am
by ftejada
I think we could apply the same assumption to Option 2. Meaning that it could be a valid sealed class declaration too if a subclass were defined in the same Java file.

I guess the question "Identity potentially valid declarations of sealed classes", especially the word "potentially" can lead to different interpretations.

Thanks.

Re: About Question enthuware.ocpjp.v17.2.3683 :

Posted: Wed Jul 20, 2022 12:03 pm
by admin
Very true indeed!
Updated again.

Re: About Question enthuware.ocpjp.v17.2.3683 :

Posted: Thu May 18, 2023 7:22 am
by Val Martinez
I cannot assume option 2,

"public sealed class DocType { }"

as a valid option.

Permits clause is required. Otherwise, it does not compile.

Please, fix it. Thank you.

Re: About Question enthuware.ocpjp.v17.2.3683 :

Posted: Fri May 19, 2023 3:58 am
by admin
permits is not required if the permitted class is in the same file.