Sunday, June 22, 2014

Abstraction

Abstraction is a process of showing functionality and hiding other internal/implementation details.

Achieving Abstraction via:-

1. Abstract class
2. Interface

Abstract class:-

Abstract class is a class which cannot be instantiated but they can be sub classed. We can declare abstract class by using abstract keyword.
  • Only abstract class can have abstract method (abstract method is a method that is declared without an implementation).
  • We cannot use private and static method in abstract class.
For Ex: - Classes Rectangle, Circle and Line inherit from MyGraphic
Abstract class
Simple Example of Abstract Class:-

AbstractionEvery non abstract subclass of MyGraphic must provide implementations for the draw and resize method:-
Abstraction

No comments:

Post a Comment