| Subclass must override methods that are declared
abstract in the superclass, or the subclass itself must be abstract. |
| |
| |
| ABSTRACT CLASSES |
| Abstract classes are those which can be used for creation
of objects. However their methods and constructors can be
used by the child or extended class. The need for abstract
classes is that you can generalize the super class from which
child classes can share its methods. The subclass of an
abstract class which can create an object is called as "concrete class". |
| |
| Following is an example |
| |
Abstract class A
{
abstract void method1();
void method2()
{
System.out.println("this is concrete method");
}
}
class B extends A
{
void method1()
{
System.out.println("B is implementation of method1");
}
}
class demo
{
public static void main(String arg[])
{
B b=new B();
b.method1();
b.method2();
}
} |
| |
| |