Explain Abstract class with suitable example.
Abstract Class :
- Abstract is a keyword.
- Abstract class is declared abstract.
- Abstract class can't be create an instance.
- Abstract class can be inherit.
- Default class is abstract then methods are automatically abstract.
- In inheritance, all base class are Abstract class.
Example of Abstract class :
abstract class Abstr
{
void disp()
{
System.out.println("Abstract");
}
}
class Demo extends Abstr
{
void demo()
{
disp();
}
}
class Abs
{
public static void main(String args[])
{
Demo obj=new Demo();
obj.demo();
}
}
output:
Abstract
Comments
Post a Comment