Saturday, October 15, 2016

Abstract Classes and Abstract methods

Abstract Classes
A class that is declared using "abstract" keyword is known as abstract class.
It may or may not include abstract methods which is abstract class can have concrete methods
(Method which has implementation) along with abstract method(without implementation) followed by semicolon

An abstract class cannot be instantiated(An object cannot be created).



Abstract Methods:

Syntax :

public abstract void display();

  •  Abstract method must be in abstract class
  • Abstract method must be overridden
  • Declaration always ends with semicolon
  • Abstract methods do not have body or implementation


Example:

abstract class test1{

  public void display()
  {



  }
abstract public void display1();
 
}

0 comments:

Post a Comment