About Question enthuware.ocpjp.v17.2.3688 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
edufin166@yahoo.com
Posts: 24
Joined: Wed Sep 28, 2022 9:41 am
Contact:

About Question enthuware.ocpjp.v17.2.3688 :

Post by edufin166@yahoo.com »

Why the option "Making the Book class extend Document will eliminate all compilation errors." is correct?

1 - "sealed class Document implements Readable permits Book{ " there is no problem here, the trouble come from "non-sealed class Book implements Readable { }" because this last one "no extends the sealed class THAT permits it.

Am I wrong?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Did you try go through the complete explanation, specially point 4? It explains exactly why it is correct.
4. When you make Book extend Document, all compilation errors will be fixed because the issues explained in points 1 and 2 above will be resolved. There will be no issue with Journal because Book itself is not sealed (even though its parent, i.e. Document, is). It is ok for a class to indirectly extend a sealed class. Only direct subclasses of a sealed class have to be listed in the permits clause.


>1 - "sealed class Document implements Readable permits Book{ " there is no problem here, the trouble come from "non-sealed class Book implements Readable { }" because this last one "no extends the sealed class THAT permits it.

As of now, there indeed is a problem with the Document class. It "permits" a class (Book) which is not its subclass class. That is why it won't compile.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 58 guests