//
Program to implement abstract classes
abstract
class abs1
{
void fun1()
{
System.out.println("Inside fun1");
}
void fun2()
{
System.out.println("Inside fun2");
}
abstract void fun3(); //abstract method
abstract void fun4(); //abstract method
}
class
A extends abs1
{
void fun3()
{
System.out.println("Inside fun3");
}
void fun4()
{
System.out.println("Inside fun4");
}
void
fun5()
{
System.out.println("Inside fun5");
}
}// end of class A
class
AbsDemo1
{
public static void main(String args[])
{
A a1 = new A();
a1.fun1();
a1.fun2();
a1.fun3();
a1.fun4();
a1.fun5();
} // end main
}//
end class
NOTE:
1)
Like interfaces, for the reference of an abstract class, we can assign the
object of the class that extends that class. With this reference, we can call
the methods of the abstract class only.
2)
If a class that is extending an abstract class does not want to provide bodies
for the methods of abstract class, then, it should also declared as ‘abstract’.
3)
We can define a class as abstract class without abstract methods.
4)
We can create abstract class reference but we can’t create abstract class
object.