ABSTRACTION

Abstraction means representation of essential features without including the background details.

ABSTRACT METHODS

-> Abstract methods do not contain the body / definition , they have just signature.

-> Abstract methods act as placeholders for methods that are implemented in the sublasses.

You will encounter abstract methods most commonly in interfaces.

public abstract String getDescription();

// no implemention or body required

 

ABSTRACT CLASSES

An abstract class is a class that does not neccessarily provide implementations for all its member functions.

An abstract class is meant to be used as superclass from which other classes are derived.The derived class is expected to provide implementations for member functions that are not implemented in the superclass.


CONCRETE CLASS

A derived class that implements all the missing functionality is called concrete class. A concrete class derives from its abstract class.

Syntax

abstract class Person

{

         public abstract String getDescription();

}

A class with one or more abstract methods must itself be declared abstract.

A class can even be declared as abstract even though it has no abstract methods.

Abstract classes cannot be instantiated. That means, if a class is declared as abstract , no objects of that class can be created.


Now, we know that we cannot create objects of abstract class.

Question arises here, then how we can access the methods of abstract class.

Hint: why we studied Inheritence.

Answer is => we will create a new class which will extends the abstract class, means our new class

can access the all the abstract methods now.

Let's see the example