Abstract class and abstract method


 

Abstract class and abstract method

In this scjp tutorial you will learn about the abstract class and abstract method.

In this scjp tutorial you will learn about the abstract class and abstract method.

Some key points about abstract methods are as following

  1. An abstract modifier identifies abstract classes and methods
  2. An abstract methods cannot be private because it defined in the other class.
  3. An abstract methods cannot be final.
  4. An abstract methods ends with a semicolon with no curly braces.
  5. An abstract methods may have parameters, a return type and throws clause.

Some key points about abstract methods are as following

  1. An abstract class may or may not necessary to have all methods abstract, it may have non abstract method also.
  2. An abstract class cannot be instantiated so it need to be a sub class of a concrete class.
  3. A single abstract method must exists in a abstract class. A concrete class cannot hold abstract method.
  4. An abstract class is meant to be used as the base class from which other classes are derived.

The above concept can be viewed in examples provided in next page.

Ads