About Question enthuware.ocpjp.v17.2.3687 :

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

Moderator: admin

Post Reply
fgomezt
Posts: 3
Joined: Wed Apr 17, 2024 7:22 pm
Contact:

About Question enthuware.ocpjp.v17.2.3687 :

Post by fgomezt »

Given the following code:

interface Readable{ } non-sealed class Device implements Readable { }

sealed class DocType implements Readable permits Book, Journal { }

final non-sealed class Book extends DocType{ }

final class Journal extends DocType{ }

Which types will fail compilation?


Book
Non-sealed implies that a class may have subclasses, while final implies that a class cannot be subclassed. Both are contradictory. That is why, a class cannot be both - final and non-sealed, at the same time.



Why is this answer correct?

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

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

Post by admin »

Because it does fail compilation for the same reason as is given. Since the question asks which types will fail compilation, option 4, i.e. Book is a correct option.

Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests