Introducing Java Abstraction Concept


Abstraction (Abstract Class)

"Abstract" keyword is used to keep a method that cannot be given specific code (Meaningless) in a Super Class created according to a certain situation.



Since there are several sub classes, the Super Class sets a Meaningless Method to override.

1. To keep Meaningless Method

2. Only an Abstract Class Method can hold an Abstract Method.

3. Abstract Class can hold any Abstract and Non-Abstract method.

4. Object and Constructor cannot be created from an Abstract Class.

5. Subclasses can use Super Keyword and create Method.

abstract class Vehicle {
 abstract void drive();
 abstract void Man;
 void Man() {
 system.out.println("Man");
 }
}
class Car extends Vehicle {
 void drive() {
 // car driven code
 }
}
class Bike extends Vehicle {
 void drive() {
 // bike driven code
 }
}

Comments

Popular posts from this blog

Introducing Java Encapsulation Concept

Introducing Java Interfaces Concept

Introducing Java Method Overriding And Super Keyword