Abstract class in java

Abstraction

Abstraction 

 

Security

Data Hiding
Encapsulation
Tightly coupled classes
Inheritance 

Code Reusability

Polymorphism
Has a relationship
 

using a abstract class (0% – 100%) to achive abstraction

Using interface (100%) abstraction

A method without body (no implementation ) is known as abstraction method

A method must always be declared in an abstract class, or we can say that if a class has an abstract method if should be declared as abstract as well

abstract class Vechicle

{

int no of jeres;                            // 100% abstraction

abstract void start();

}

if a regular class extends an abstraction class, then the class, then the class must have to implements all the abstract methods of abstract parent or it has to be declared abstract as well

class car extends Vehicla

{

void start()

{

System.out.println(“Car Start”);

}

}

abstract method in a abstract class are meant to be overridden in derived concrete classes otherwise compile-time error will be thrown

class  Scooter

extends Vehicla

{

void start()

{

System.out.println(“Kick”);

}

}

Abstract classes cannot create objects