Abstract Class


Abstract Class

An abstract class is a class that cannot be instantiated. The class may contain any or none of the following:

The purpose of an abstract class is to list items that are common to its sub-classes. An abstract class must be declared with the keyword abstract. An abstract cannot be instantiated. However, you can declare a variable of such a class.

The format for declaring an abstract class is as follows:


	public abstract  class name
	{
		 	:
		public abstract return_type method();
		//Definition cannot be supplied.
			:
	}

Abstract Method

An abstract method is one that is declared but its body is not implemented. The following rules govern the way one uses an abstract method:

Relationship between an Abstract class and its direct sub-class


Demo Program No. 3
  • holiday.java
  • attraction.java
  • symphony.java
  • movie.java
  • myMovie.java
  • deadMovie.java
  • Go Back