Thursday, June 11, 2015

JAVA - Introduction to Object Oriented Programing(OOP)

Objects

An application/software solution when designed can be broken into Objects similar to real world objects.And every object has a State and Behavior.
eg: A banking  application will have Accounts(different account holders with a unique Account Number and having other details line name, address etc),Cards(havng properties card number, expiry date) and so on.

Class

Class is a type for the object,blueprint from which individual objects are created.
A Class defines the state(as Fields that can contain a value) and behavior(as Methods) of an object.
eg: We can define a Class Account to create Account objects(for diff account holders).
And Account class will contain the properties of an account as its Fields - Account Number, Name, Address, Branch name etc. And Methods to alter the Fields - method to edit Address or Branch details.

Main Concepts in OOP(Object Oriented Programming)

Encapsulation - defining the state and behavior of an object in a class.
Data Hiding - by defining a class the details of an object is not known to the external world.
Modularity
Modularity and Reusability - Defining classes for different objects breaks the application into readable modules that can be Reused where ever needed.