Saturday, December 12, 2020

Learn Abstract Class and Interface - Day 11

 In this article .we are learn Abstract Class and Interface.

Abstract Class:

  • Abstract class is declared by using keyword abstract.
  • Abstract classes are mainly for inheritance where other classes may derive from them.
  • An abstract class can be derive by using ‘extends’ keyword. 
  •  We cannot create an instance of an abstract class.
  • Abstract class is a class that includes both abstract and regular methods.
  • Methods within abstract class which are marked as abstract do not contain an implementation and must be implemented in derived classes. 
  • So the  abstract class is used for inheritance where other classes are derived from abstract class.
  • Syntax:-
abstract class ClassName{

//variables declaration;
//abstract or non-abstract methods;

}





Interface:
  • It is like a blueprint of class, only method implementation is not possible in interface.
  • It contains properties, methods & events.
  • Users have to give method definitions in implemented class of interfaces.
  • We can implement an interface by using the implements keyword in class.
  • An interface is a contract which defines a function with respect to parameters or arguments and data types.
  • Interface supports multiple inheritance.
  • Interface can't contains the implementation of abstract class.
  • Syntax:
interface InterfaceName{    

     // properties, methods & events

}   






Thank you....

No comments:

Post a Comment

Function in SQL -part 8

  In this blog we are going to understand  Sql function.   FUNCTION: A function is a database object in SQL Server. It accepts only input pa...