Ben Pittens wrote:According the Boyarsky and Selikoff book(chapter 5, page 265 rule 4) abstract classes are allowed to be protected.
When I look at the abstract class definition rules on page 265, rule 3 states: "
Abstract classes may not be marked as private or final". So I guess this is the rule you are referring to (instead of rule 4).
Ben Pittens wrote:Can anybody give me an example of a protected abstract class in use?
Top-level classes (and other types) can only have
public or
default (package-private) access. Other access levels (
private and
protected) are not allowed. This rule applies to all classes (and other types), not only to abstract classes.
Your class
test20 is a top-level class, so you have only two allowed access levels
When your class is nested inside another class, you can have one of the four access levels as illustrated in this code snippet
Any of these outer or inner classes can be marked as abstract as well. Please note that nested classes are not on the OCA exam (but will be on the OCP exam). So I think you have discovered an errata item (and I have to say I'm a bit surprised it's not yet on the
official errata overview). Rule 3 should read as: "
Abstract classes may not be marked as protected, private or final".
Hope it helps!
Kind regards,
Roel