Tuesday, 3 September 2019

OOPS concepts and exmples

Object Oriented programs and concepts 


What is Object oriented program 



Object oriented program is the concept of the principle that works objects are most important of  a program that users are building. An object is set of  variables, methods  and objects. Manipulating the objects to get the result is the aim of object oriented program.

OOPS Concepts 

Class 
Object 
Inheritance 
Abstraction
Encapsulation
Polymorphism 
Association 
Aggregation
Composition 

Class  :

A class is user defined blueprint or prototype  for which the objects are created. It can simply say combination of variables , methods and other objects .


Object:

Object is self contained component which consists of method and variables which makes particular type of data is useful to user. In simple terms Object is the instantiation of a class , which is ready to use for a purpose .

Inheritance:

Inheritance, is the concept of acquiring/getting/using  the properties of another object in one object, basically creating  parent child relationship between classes. 

the keyword extends used to inherit the properties . Class A extends B means , all the properties of B can be used in Class A.

Abstraction:

Inheritance Abstraction is the process by which the data and programs are defined with representation while hiding the implementation details.
In simple terms , Abstraction is  to hide the information which is not relevant to others/other objects.

Encapsulation:

Wrapping data and methods within classes in combination with implementation hiding (through access specifiers/modifiers) is called encapsulation.  Encapsulation essentially has both  information hiding and implementation hiding.

Polymorphism:

Polymorphism is the ability by which, the functions or reference variables which behaves differently in different programmatic context.

two types of polymophisms available:

Compile time polymorphism (static binding or method overloading)
Run-time polymorphism (dynamic binding or method overriding)

Association:

Association is the concept of building relationship between two classes , but the association defined as is a relation or has a relation between classes .

Aggregation:

Aggregation is the concept of having relationship only in one direction .

Composition :

Composition is the type of both directional relationship. Object A to B and B to A , if the Object A is not defied Object B will not exist and Object B is not defined Object A will not exist. 







No comments:

Post a Comment