Home Tutorial Java Certification Abstract class and abstract method

 
 

Abstract class and abstract method
Posted on: June 30, 2010 at 12:00 AM
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.

Abstract class or methods example-1
This example shows that a abstract class can hold abstract and non abstract methods.
 
Abstract class or methods example-2
In this example you will see that an abstract class can extend another abstract class.
 
Abstract class or methods example-3
This motive of this code is to show that an abstract class can hold abstract and non abstract classes
 

Related Tags for Abstract class and abstract method:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.