Abstraction (Cont.)


An Abstraction Example (Cont.)
Few details about the program are given next:
public Shape( String color ) { this.color = color; }
The this keyword refers to the current object.

super( color );
It is used to invoke the constructor of its parent class, and the super keyword refers to a class’s base class in a method or constructor.

@Override
The @Override annotation is used when we override a method in subclass, though it is not mandatory to use this annotation.

int area( ) { return (int) ( Math.PI * Math.pow( radius, 2 ) ); }
The command “(int)” is type casting, which converts a double value to an integer value. The field Math.PI is the value close to π (3.14), and the method Math.pow(double a, double b) returns the value of the first argument raised to the power of the second argument.
Abstraction vs Encapsulation Advantages of Abstraction


      “Never, never, never give in!”    
      ― Winston S. Churchill