Java Abstract Class:
We can use the Eclipse IDE for this example. If you do not know about it then follow this link- How to Install Eclipse For Java and create a program in it. |
- An abstract class is declared using the keyword abstract.
- It may or may not contain abstract methods.
- An abstract class must be inherited by some other class.
- If the derived class does not provide the implementation of any abstract method present in an abstract class, the derived class must be declared as abstract.
- Objects of an abstract class cannot be created, but reference can be created.
- Through the reference of an abstract class, only methods of the abstract class implemented in the derived class can be called.
- The abstract keyword cannot be applied to static methods or constructors.


abstract class Base
{
abstract void show();
}
class first extends Base
{
void show()
{
System.out.println("show of first");
}
}
class second extends Base
{
void show()
{
System.out.println("show of second");
}
}
abstract class third extends Base
{
}
public class Abstract_method {
public static void main(String[] args) {
// TODO Auto-generated method stub
Base b = new first();
b.show();
b = new second();
b.show();
}
}
Comments (No)