[HD-OCP17/21-Fundamentals Pg 336, Sec. 13.3.4 - creating-sealed-classessealed-classes]

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

Moderator: admin

Post Reply
raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

[HD-OCP17/21-Fundamentals Pg 336, Sec. 13.3.4 - creating-sealed-classessealed-classes]

Post by raphaelzintec »

hello this doesnt work for me

"All direct subclasses of the sealed class must be listed in the permits clause except when they
are defined in the same source file. If all the subtypes are coded in the same source file, the
compiler infers the permits clause on it own and saves the developer from typing a few keystrokes
without affecting readability of the code much."


here same source file but i have error on the last line:

Code: Select all

sealed public class Abs permits Con {}
non-sealed class Con extends Abs{}
non-sealed class Con2 extends Abs{}

raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

Re: [HD-OCP17/21-Fundamentals Pg 336, Sec. 13.3.4 - creating-sealed-classessealed-classes]

Post by raphaelzintec »

sorry ive made another test, it works only if you dont type permits key word at all

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests