Search This Blog

Tuesday, December 17, 2013

Encapsulation is one of the major properties of OOP. How is it implemented in software terms?
Encapsulation is a way to implement data hiding and abstraction by wrapping up data and associated functions into single unit called object.
                               An object binds together data and its associated functions under one unit thereby enforcing encapsulation as encapsulation means wrapping up data and associated functions together into a single unit.
What is polymorphism?

It is the ability of representing a thing in more than one form. Polymorphism is used in constructor overloading.
What are data members & member functions?
The variables which are define globally in the class  just after the defining  of the class name. For E.g.
Class pen
{
int a,int b; //Data Members
{
public void cap()   //member function
{
…
…
..
…
…
}

}
What is inheritance?
Inheritance is a technique which is used to derive or build new classes from existing class. A class may be derive from one or more classes. The new classes are called derived class or sub class and existing class is called base class or super class. The derived class inherit the property of its base including its data members and member methods. It can also add its own member method and data members.
BENEFITS:-
        ·        Data in existing class can be modify easily.

        ·        Object oriented hierarchy can be built.
What is class?
A class is collection of object. It is a user defined aggregate data type. A class may be defined as a group of object with same attribute and operations. For E.g. the color (class) contain various color; red, blue, etc. (objects)
Class contain the following attributes or members:-
         a)      Data Members
         b)      Member functions

         c)      Constructor

Thursday, December 12, 2013

What is encapsulation?
Encapsulation means characteristics and behavior are combined in one unit. In other words, encapsulation is the way of combining both data (characteristics) and the function (behavior) that operates on that data under a single unit.

The wrapping up of the data into a single unit is known  as  encapsulation.
OBJECTS ENCAPSULATE STATE AND BEHAVIOUR

Can you clearly make out what this statement –“objects encapsulate state and behaviour”- is trying to convey? No? Same problem was with me also but when I read it for the first, go deep and you will find easy. Well let’s first discuss a term called encapsulation, after which the above statement will become clear to you. We shall also talk about linked term ”abstraction” to understand it more clearly.
What is abstraction?
Abstraction is a concept of simplifying a real world concept into its essential elements.
    Abstraction refers to the act of representing essential feature without including the background details or explanations.

To understand abstraction let us take an example. Suppose you are driving a car.You only know the essential features to drive a car i.e. gear handling, steering handling,use of clutch, brakes,accelerator etc. But while driving do you get into internal details of car like wiring, petrol tank, motor workingetc. ? You just change the gear or apply the brakes etc. What is happening inside is hidden from you. That what abstraction is, where you only know the essential things to drive a car without including the background details or explanations.
INTRODUCTION
The world we live in is composed of objects. Everything that we see is an example of object. We ourselves are examples of objects. The chair you are sitting on is another example of objects. The car, your father drives is also an example of object. The pets in your house are also objects. The list is endless.
Aren’t you wondering what this objects all about is? Why are we referring to everything as an object? Well, answer to all these questions, you will find in coming lines. This chapter is dedicated to the discussion of concepts of objects. Let us begin with what exactly an object is.
What is an object?
An object, in real world, can be one of the following:
·        Anything that is visible or tangible.
·        Something that may be apprehended intellectually.
·        Something towards which one can direct action or thought
If we study all things meeting above criteria of being objects , we can say that each of these has a unique identity , some definitive state or characteristics and some behavior .For instances , we can say that an ”ORANGE” is an object . Its characteristics are: it is spherical shaped; its color is orange etc. Its behavior is: it is citrus in nature and it tastes sweet sour. Similarly, we can say that your chair is also an object. Its characteristics are: it has four legs, a back, may or may not have arms. Its behavior is: it let you sit on it. With this description can you suggest some more object examples?
Keep thinking, in the mean time, we define object as follows:
An object can be thought of as an entity having specific identity, specific characteristics and specific behavior.
OR
Java is on object oriented programming language. An object is a self contained element of computer program that represent a related group of feature and is design to do specific task. Objects are also called instances.
      Every object has the following inbuilt characteristics, which we had already discussed above:-
            a)      Identity :- it is the name by which an object is recognize. E.g. pen ,box, chair etc.
            b)      State :- the object may be in any state that is processed or unprocessed. For example the computer may be in any of the following state; on state ; off state; out of order.
             c)      Behaviour :- this refers that what an object is capable of doing.

NOTE: The state of an object is represented through the values/attributes of its characteristics at a given point of time.