Alphalearningschool
        

<<< Prev

Next >>>

Up
Object-Oriented programming System

Introduction to OOP

    

OOP Stands for “Object Orient Programming”. It is a technique, not technology. It means, it does not provide any syntaxes or API, instead it provides suggestions to design and develop objects in programming languages.

Why OOPS??

    

OOP is a methodology; it is introduces to represents real world objects in programming world by achieving security and dynamic binding.

All living and non living things are considered as objects. So the real world objects such as person, Animal, Bike, Computer, etc. can be created in OOP languages by using class. 

Definition of OOP:

OOP is a Methodology that provides a way of modularizing a program by creating partitioned memory area form both data and methods that can be used as template for creating copies of such modules (objects) , on demand.

Building blocks of OOP:

 The building blocks of OOP are

  • Class
  • Object 

Every Java program must start with a class, because using class only we can represent real world objects like Person, Bike, Animal etc. 

Definition of class, Object and their relationship: 

Definition of class

  • A class is a specification or blue print   or template of an object that defines what goes to make up a particular sort of object. Class is logical construct an object has physical reality.
  • A class defines the structure, state and Behavior (data & code) that will be shared by a set of objects. Hence each objects of a given class contains the structure, state and behavior defined by the class. 

 

Definition of object

  • Object is the physical reality of a class.
  • Technically object can be defined as “It is an encapsulated form of all non-static variables and non-static methods of a particular class.
  • An instance of a class is the other technical term of an object
  • The process of creating objects out of class is called instantiation
  • Two objects can be communicated by passing messages (arguments).

 Below diagram shows the meaning of logical construct and physical reality

    

 Object’s Characteristics:

 A real world objects contains below three characteristics

  • State                - It is object properties                      - like name, height, weight, etc….
  • Behaviour        - It is operations of object                 -like sleep, walk, run, eat, etc…
  • Identity            -  It is identity of object                      -name

     

More Explanation:

State

  • Instance variables value is technically called as object state
  • An object’s state will be changed if instance variables value is changed.
  • A change in a state of an object must be a consequence of messages sent to the object.
  • It means non –static variables must be changed only via setter methods not directly.

 

Behaviour

  • Behaviour of an object is defined by instance methods.
  • Behaviour of an object is depends on the messages passed to it
  • Message is passed to objects through methods.
  • So an object Behaviour is depends on the instance methods.

 

Identity

  • Identity is a unique property using which one object can be differentiated from other object. Technically identity is also called as hashcode.

 

Instance

  • An instance is a single , unique memory allocation of a class that represents that object physically with specific values:

                      -For Example Bike [8192. “Pulsar 180”, BLCAK].