java2db

Difference between abstract class and concrete class in java



A partial implemented class is called an abstract class , Where as fully implemented class is commonly known as concrete or normal class.

 

 

abstract class and concrete class in java Abstract class:
abstract class and concrete class in java It is must to declare a class with an abstract access modifier .
abstract class and concrete class in java May or may not contain abstract methods.
abstract class and concrete class in java It is not possible to instantiate a abstract class .
abstract class and concrete class in java Variables are not final by default.We can able to reassign values.
abstract class and concrete class in java The abstract methods should implement in the derived classes. If not , the derived class also become an abstract class.
abstract class and concrete class in java Interface implementation is possible.

 

 

 Concrete class:
  Should not declare a concrete class with an abstract access modifier.
  Should not contain abstract methods.
abstract class and concrete class in java  Instantiation is possible for a concrete class.
abstract class and concrete class in java  Variables are not final by default.
abstract class and concrete class in java  There is no abstract methods in any level to implement .
abstract class and concrete class in java  Interface implementation is possible.

 

Syntax :

 public abstract class <class name>
{
//variables
//abstract methods with ; (not mandatory)
//implemented methods
}
 public  class <class name>
{
//variables
//implemented methods
}

 

 

abstract class and concrete class in java Example code for abstract class :

The preceding example  having one abstract method and the class declared as an abstract class.If any class extends the abstractBase ,It is required  to implement the abstract method called bank_details().

 

 

abstract class and concrete class in java Example code for concrete class :

In the above example code, There is no  abstract access modifier in front of the class (concreteBase) declaration and no abstract methods.Now it is a normal or concrete class.
 If any method declared as an abstract , must declare the class as an abstract.

 If any class is declared as an abstract ,it is not mandatory to declare an abstract methods in that class.




Related Posts :
Difference between Iterator ListIterator and Enumeration in java
   [will not be published]



^ <