Abstraction in Java | Core Java Course

This Core Java Course”Abstraction in Java” is providing the defining of abstraction and what is abstract class and how to use abstract classes in java application.


 

Abstraction:

  • Abstraction is the concept of hiding unnecessary details of Object in communication.
  • Abstraction shows only essential features of Object.
  • Abstraction provides the information about “What object can do instead how it does it”.
  • Abstraction is the “General View” of Object.

 

Following example explains clearly internal structure of Object which is not visible to all the objects.

Object abstraction

 

Abstract class:

  • Partial definition of Object.
  • If a class is not able to provide definition to all the methods referred as Abstract class.
  • “abstract” is a pre-defined keyword used to define abstract classes.
  • Abstract class also saved with ‘.java’ extension only.
  • ‘.class file’ will be generated when abstract class has compiled.

Abstract class definition in java

 

  • ‘abstract’ modifier is used to define abstract classes.
  • Abstract class is allowed to define
    1. Abstract methods(methods don’t have body)
    2. Concrete methods(methods having body)

 

  • Abstract class was not fully defined.
  • We cannot instantiate abstract class(partially defined).
  • We can instantiate only classes using ‘new’ keyword.

 

Share this