Saturday, 28 October 2017

Abstract Class With Appropriate Example

Abstract Class

→ Abstract is a keyword to declare an abstract class.

→ The abstract methods must be in abstract class.

→ We can't create an object of abstract class.

→ All base class are the abstract class.

→ No object can be created of abstract.

→  The Abstract class must be inherited.

→ The abstract class must be extended by at least one subclass.

→ All abstract method must be overridden.

  

Example of abstract class

abstract class A{} 

Example abstract method

abstract void printStatus(); 

Example :


abstract class Hi

{
     abstract void run();
}
class Hello extends hi

{
     void run()

     {
            System.out.println("Welcome");
     }
     public static void main(String args[])

    {
            Hi obj = new Hi();
            obj.run();
    }   



Popular posts