Wednesday, 21 May 2014

OOPS Concept with simple examples


OOPS CONCEPT WITH SIMPLE EXAMPLES

This question is frequently asked question in the interview and it is most important question.....
Here i explain the oops concept with simple day today life example

Objects: Object is the basic unit of object-oriented programming.Objects are identified by its unique name. An objectrepresents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.


Classes: Classes are data types based on which objects are created.Objects with similar properties and methods are grouped together to form a Class. Thus a Class represent a set of individual objects. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects becomes functions of the class and is referred to as Methods.

Example:
Here before build a house we prepare a Blue print it is called CLASS
By using the blue print we build the house. Here the house is called OBJECT.
In the house some people are living the are called DATA

Abstraction: Abstraction means showing essential features and hiding non-essential features to the user.

Example:
In the Data base we store the value by using the query.
it will store. It is front end. But it will not show how it store in the memory.
Here the storing process is hidden it is called Abstract

Encapsulation: Encapsulation means which binds the data and code (or) writing operations and methods in single unit (class).
OR
Warping the data in to a single unit is called encapsulation.......

Example:
In the bike have many part like wheel, Centimeter cubic(CC), Piston etc.... This collection of part is called Bike



Inheritance: Deriving a new class from the existing class,is called Inheritance.
Derived(sub class) class is getting all the features from Existing (super class\base class) class and also incorporating some new features to the sub class.


Polymorphism :
Polymorphism means ability to take more than one form that an operation can exhibit different behavior at different instance depend upon the data passed in the operation.
 
Example: 
A boy is act as student in class.
He act as son in home....
He act as friend With his friends circle
 
 
This are the concept and example of the oops concept......
All the best.......

No comments:

Post a Comment