Sometimes when creating base objects you want to create methods that are overridable by object that inherit the base object, but keep the methods from being public. However, the compiler throws an exceptions when you try to define a method as “Private Abstract”.
Why doesn’t the compiler like “Private Abstract” methods?
The reason for this is Private methods can not be overriden. So, essentially the Abstract is useless if the method is Private.
How can I create a “Private” method that’s able to be overriden?
Simple, you just declare the method as “Protected Abstract”. Protected defines that the method is only accessible from within the class that declared it, and from within any derived class.
- 01 Jul 2020
- 06 Apr 2020
- 11 Mar 2020
- 15 Feb 2020
- 02 Jan 2020
Recent on Build5Nines.com
This site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. We also participates in affiliate programs with Udemy, and other sites. This site is compensated for referring traffic and business to these companies.