Home Tutorial Java Certification Abstract class and abstract method

 
 

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

Related Tags for Abstract class and abstract method:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 30, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com