Java Programming
Abstract class in Java
A class that is declared with abstract keyword, is known as abstract class. Before learning abstract class, let's understand the abstraction first.Abstraction
Abstraction is a process of hiding the implementation details and showing only functionality to the user.
Ways to achieve Abstraction
There are two ways to achieve abstraction in JAVA
1. Abstract class (0 to 100%)
2. Interface (100%)
Example
abstract class Bike
{
abstract void run();
}
class Honda extends Bike
{
void run()
{
System.out.println("running safely..");
}
public static void main(String args[])
{
Bike obj = new Honda(); obj.run();
}
}
Comments