Abstract class in Java

Abstract class in Java


Abstract class in Java as the interface, but may contain the default execution method. The abstract class can have abstract methods without the body and can have methods with the application.
Classes are declared as abstract, known as abstract classes. It can have abstract and non-abstract methods.

·         Abstract classes must be declared and the keyword is abstract.
·         They may have abstract and non-abstract methods.
·         should not encourage.
·         They can have a static and solid builder as well.
·         They may have work that will force the subclass method not to change the body.

package Mypkg;
public class myabs {
      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
        System.out.println("Entered myabs-Main() ");
        System.out.println("***************************************");
            useabs ob=new useabs();
            ob.getDisplay();
            ob.getD();
        System.out.println("***************************************");
        System.out.println("Exited  myabs-Main() ");
      }
}
abstract class myabsEx
{
      abstract void getDisplay(); // Abstract method
      void getD() // other method
      {
            System.out.println("This is normal method inside Abstract class");
      }
}
class useabs extends myabsEx
{      void getDisplay()
      {
            System.out.println("This is re Definition given of  Abstarct method class");
      }
}


Output :
Entered myabs-Main()
***************************************
This is re Definition given of  Abstarct method class
This is normal method inside Abstract class
***************************************
Exited  myabs-Main()


Comments

Post a Comment

Popular posts from this blog

Introduction to Apache Spark with Scala:

Java Array