Day 10 : TypeScript
In this blog we are going to understand the abstract and interface.
Abstract class :
- Semantically an abstract class is a half defined parent class.
- An abstract class is mainly used for inheritance where other classes derive from them.
- Abstract class is defined using "abstract" keyword.
- We cannot create instance of an abstract class.
- The classes which extends the abstract class must define all the abstract methods.
- The abstract classes not contain the function or method body.
Example :
Generalization :
- Generalization is a another word for parent class.
- Generalization is the process of extracting shared characteristics from two or more classes and combining them into a class or superclass.
Specialization :
- Specialization is a another word for child class.
- Specialization is the process of creating new subclasses from old one.
- The child class also named as concrete class.
Interface :
- An interface is an abstract type but not contain any code like a 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.
- Interface is declared using "interface" keyword.
- Interface can be implemented using "implements" keyword.
- Syntax :
public interface Sample
{
void work();
}
* Interface can have the abstract, default and static methods *
Thank You!!!
For more understanding watch below video :
JavaScript Day 1 : Day 1
JavaScript Day 2 Global Pollution : Day 2 Global
JavaScript Day 2 Undefined and Hoisting : Day 2 Undefined
JavaScript Day 3 : Day 3
JavaScript Day 4 : Day 4
JavaScript Day 5 : Day 5
JavaScript Day 6 : Day 6
TypeScript Day 7 : Day 7
TypeScript Day 8 : Day 8
TypeScript Day 9 : Day 9
Comments
Post a Comment