Docstoc

properties of oops

Document Sample
properties of oops Powered By Docstoc
					                Objective


On completion of this period you would be
able to learn…


     • Properties of OOPS




                   CM505.3                  1
                 RECAP


• What is the OOP?



• What are the features of OOPS ?




                     CM505.3        2
       Properties of oops

•   Object
•   Class
•   Encapsulation
•   Data abstraction
•   Inheritence
•   Polymorphism



                CM505.3     3
                      Objects

• Objects are the basic run time entities.
• Can be defined as an identifiable entity
 with characteristics and behavior.
• We are often surrounded by variety of
 objects like
            • computer
            • chair
            • telephone etc.,
                         CM505.3             4
    Characteristics of Object


• State


• Behavior


• Identity




               CM505.3          5
        Characteristics of Object
Example:-
Consider the object telephone it has
• a set of attributes like color, shape, and model
etc.,


• Behaviour is that it announces a call.


• Identity is the unique telephone number.

                       CM505.3                       6
        Object communication

• Objects interact with each other by sending
  messages to each other.

• It occupies space in memory.

• Each object is having its own address.




                    CM505.3                     7
          Object communication

• Each object contains data and some code to
manipulate the data.
  • for example
                  Object: Student

                  DATA:
                      Name
                      Marks

                  FUNCTIONS:
                      Total
                      Average




                         CM505.3               8
              Object communication


• Objects have life cycle.



• They can be created and destroyed.


• Communication with an object is feasible as long
as it is alive.



                         CM505.3                     9
                    Classes
• It is defined as a collection of objects of similar type.


• The set of data and code of an object can be made a
  user defined data type using a class.


• In fact objects are variables of type class.


• We can create any number of objects belonging to
  that defined class.

                           CM505.3                      10
                   Classes

Example:-
banana, apple and mango are the examples of
members of class of fruit.


• If fruit is defined as class then
   Fruit mango;
   Will create an object mango belonging to the
   class fruit.
                        CM505.3                   11
             Encapsulation

• The wrapping up of data and functions into single

 unit is known as ‘ENCAPSULATION’.


• The data is not accessible to outside world.


• Only the member functions within the class can
 access the data.

                        CM505.3                    12
             Encapsulation


•These functions provide an interface between the
object’s data and the program.


• This insulation of data from direct access by the
 program is called data hiding.


                       CM505.3                        13
             Data Abstraction

• Abstraction refers to the representation of essential

 features without including background details or
 explanations.


• Since the classes use data abstraction they are
 also known as Abstract Data Type (ADT).


                        CM505.3                     14
               Inheritance
• It is the process of creating a new class from
  the existing class.


• The new class inherits all the characteristics of
  the existing class.


• It is like a hierarchical classification.




                        CM505.3                    15
                Inheritance

• We can add additional features to an existing
  class without modifying it. This is known as
  reusability.


• Each derived class shares common
  characteristics with the class from which it is
  derived.


• The new class will have combined features of
  both the classes.

                        CM505.3                     16
Inheritance




 CM505.3      17
              Polymorphism
• The ability to take more than one form.

• An operation may exhibit different behaviours in
  different instances.

• The behaviour depends upon the types of data
  used in the operation.

• Polymorphism is used extensively in
  implementing the inheritance.

                      CM505.3                    18
Polymorphism-Example




       CM505.3         19
Polymorphism-operator over loading


•Consider the operation of addition.


• For two numbers it generates a sum.


• If the operands are string then the operation
 would produce a third string by concatenation.



                      CM505.3                     20
Polymorphism-operator over loading


•The process of making an operator to exhibit
 different behaviours in different instances is
 known as operator overloading.


• A single function name can be use to handle
 different members and different types of
 arguments.

                      CM505.3                     21
  Polymorphism – function overloading


• It is nothing but a particular word in having several
different meanings depending on the context.


• Using a single function name to perform different
types of tasks is known as function overloading.




                        CM505.3                      22
             Dynamic binding


• It is also known as late binding.



• The code associated with a given procedure is
not known until the time of call at run time.




                         CM505.3                  23
           Summary


You have learnt…


• Properties of OOPS.




                   CM505.3   24
Frequently Asked Questions


• What is an inheritance?



• What is the polymorphism?


• What is dynamic binding?


             CM505.3          25
                       Quiz

1   The insulation of data from direct access by
    the program is called as __________.




                       CM505.3                     26
                       Quiz

1   The insulation of data from direct access by
    the program is called as Data hiding.




                       CM505.3                     27
                      Quiz

1   The wrapping up of data and functions into
    single unit is known as _________.




                       CM505.3                   28
                      Quiz

1   The wrapping up of data and functions into
    single unit is known as Encapsulation.




                       CM505.3                   29
                      Quiz

1   A class is defined as a collection of _________
    of similar type.




                       CM505.3                    30
                       Quiz

1   A class is defined as a collection of Objects of
    similar type.




                        CM505.3                        31
Thank you




   CM505.3   32

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3
posted:3/10/2012
language:
pages:32