• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Erratum OCP Java 17 Developer Complete Study Guide/Chapter 7/Review questions/Question 14/Option D

 
Greenhorn
Posts: 2
1
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Original sentence:
"A sealed class can be extended by a subclass that uses the non-sealed modifier."

Expected sentence (assuming option D is supposed to be incorrect as per the answer to review questions):
"A sealed class can be extended by a subclass that uses the nonsealed modifier."

Thank you.
 
Master Rancher
Posts: 4661
63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm, I don't have the text of the full question... but "nonsealed" is not a modifier in Java.  Instead, "non-sealed" is correct.  JLS 17 8.1.1.2 sealed, non-sealed, and final Classes
 
Favio Tejada
Greenhorn
Posts: 2
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me quote the question/answer so that you better understand:

Question:
Which statements about sealed classes are correct? (Choose all that apply.)
A sealed interface restricts which subinterfaces may extend it.
B sealed class cannot be indirectly extended by a class that is not listed in its permits clause.
C sealed class can be extended by an abstract class.
D sealed class can be extended by a subclass that uses the non-sealed modifier.
E sealed interface restricts which subclasses may implement it.
F sealed class cannot contain any nested subclasses.
G None of the above

Answers to review questions:
A, C, E.  A sealed interface restricts which interfaces may extend it, or which classes may implement it, making options A and E correct. Option B is incorrect. For example, a non-sealed subclass allows classes not listed in the permits clause to indirectly extend the sealed class. Option C is correct. While a sealed class is commonly extended by a subclass marked final, it can also be extended by a sealed or non-sealed subclass marked abstract. Option D is incorrect, as the modifier is non-sealed, not nonsealed. Finally, option F is incorrect, as sealed classes can contain nested subclasses.



There is clearly a confusion with the expected answer, so there are two alternatives to correct the erratum:
- update option D with nonsealed so that the answer makes sense, or
- update the answer by adding option D as correct, also the phrase "Option D is incorrect, as the modifier is non-sealed, not nonsealed." should be changed to "Option D is correct, as the modifier non-sealed is valid."
 
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct. I've added this to the errata. I also traced it back. We wrote this correctly (in that it didn't have the dash and was therefore wrong.) The dash got added in editing .
 
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic