top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between abstract class and concrete class in java?

+2 votes
479 views

What is the difference between abstract class and concrete class in java. If concrete class is final then how can inherit concrete class, can someone please explain in detail?

posted Sep 7, 2015 by Anamika

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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

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 Instantiate 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
}

Example code for abstract class :

public abstract class abstractBase {
//fields
private String account_Num = "123415";
private String person_Name = "Rose";
private String person_email = "rose1234@xxx.com";
protected String Status = "A";
//implemented method 
public void person_Details()
{
System.out.println("Account number : "+account_Num );   
System.out.println("Name :"+person_Name);   
System.out.println("Email : "+person_email);    
}

//Abstract method 
public abstract void bank_details();
}

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().

Example code for concrete class :

public  class concreteBase {
//fields
private String account_Num = "123415";
private String person_Name = "Rose";
private String person_email = "rose1234@xxx.com";
protected String Status = "A";

//All implemented methods 
public void person_Details()
{
System.out.println("Account number : "+account_Num );   
System.out.println("Name :"+person_Name);   
System.out.println("Email : "+person_email);    
}

public  void bank_details()
{
System.out.println("Here is the code for bank_details");    
}
}

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.

answer Apr 27, 2016 by Karthick.c
...