What is modifiers ?

Modifiers are just like a keywords of java that gives the compiler information about the nature of code,classes or data. Here the group of modifiers are called access modifiers.

Tell me about Public in access modifiers ?

Public is most generous access modifiers in java. Without any restriction we can use any public class, variable or method in any java program. Any subclass may override any public method. we can invoke main() from any java runtime environment once the main() method is declared as public in an application.

Briefly about private in access modifiers..

Private is a least generous access modifier in java. it may not be declared for top level classes. A private variable may be used only by an instance of the class that declares the variable or method.

Tell me the rules for overriding in method access.

Here the rules :

  • A private method may be overridden by a private, default, protected, or public method.
  • A default method may be overridden by a default, protected, or public method.
  • A protected method may be overridden by a protected or public method.
  • A public method may be overridden only by a public method.
What is an abstract class in java?

Abstract class is a class which contain one or more abstract methods, which has to be implemented by sub classes. Abstract classes define an abstraction and leave concrete implementation details to subclasses.