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?
About Question enthuware.ocpjp.v17.2.3687 :
Moderator: admin
-
- Posts: 3
- Joined: Wed Apr 17, 2024 7:22 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v17.2.3687 :
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.
Who is online
Users browsing this forum: No registered users and 22 guests