At root level an Abstract Class can be Public only. As an inner class they can be public, private or protected. There are various reasons for declaring them any of these.
Abstract public classes can be useful if you want to use the class from inside but want to leave the option of using it outside. [common]
Abstract private classes can be useful if you intend on extending the class inside but do not want it accessible to any outside classes or extended classes. [rare]
Abstract protected classes can be useful if you want to make the class extendable by sub-classes only. [common]
The same rules and motivations apply to methods as well except abstract methods cannot can be declared private. The only situation in which a private abstract method would be needed would be the same as the rare class access above but in this scenario the word abstract is redundant so it is prohibited.
I'll only show the rare example here:
public abstract class RootClass
{
private abstract class InsidePrivate
{
private void method2()
{
// abstract is redundant for this method so it's not allwoed
// the same functionality can be provided by leaving the body blank
}
private class InsideExtender extends InsidePrivate
{
// this class is extending a private abstract class
// InsidePrivate can only be extended by inner classes
// it is invisible to outside classes, and to extended-classes of RootClass
private void method2()
{
// replaces method2 in InsidePrivate,
}
}
}
}
Use of this functionality is rare, but it is mainly used in data structures such as HashMaps etc where these classes are utility classes defined to do a specified function which no outside class should ever need to access or know about i.e. in areas where Abstraction is used.