+ All Categories
Home > Documents > Chapter0_ObjectOrientedProgramming

Chapter0_ObjectOrientedProgramming

Date post: 07-Jan-2016
Category:
Upload: ghuru
View: 214 times
Download: 0 times
Share this document with a friend
Description:
oop
Popular Tags:

of 19

Transcript

Slide 1

UNIT- ICHAPTER IN BOOK- 0OBJECT ORIENTED PROGRAMMING-K. IndhuSYLLABUS COVERED HEREK. INDHU2Object Oriented ProgrammingGoalsK. INDHU3What is an Object ?What is a Class ?What is a Message ?Conditions to be Object Oriented ?What is Encapsulation ?What is Abstraction ?Objects Access Levels (Visibility) ?What is Inheritance ?Inheritance Pictorially ? Properties of Inheritance ? Benefits of Inheritance ? What is Polymorphism ? Types of Polymorphism ?What is Dynamic Binding ?

What is an object ?K. INDHU4What is an Object?-> An object is a software bundle of related variables and methods.

-> Software Objects are often used to model real-world objects which we come across in everyday life.

What is a class ?K. INDHU5What is a Class?-> A class is a blue print or prototype that defines the variables & the methods, common to all objects of a certain type.

-> A class encapsulates both data & operations.

-> Object is run-time instance of class.

-> Classes just sit there, objects do the real work.

-> Memory is allocated for Objects, not for Classes.What is a message ?K. INDHU6What is a Message ?-> Software Objects interact & communicate with each other using messages.

-> Programmatically, Methods (functions in C) are called as Messages.

Conditions to be object orientedK. INDHU7To be object oriented, a language must support->-> Encapsulation,-> Abstraction,-> Inheritance,-> Polymorphism,-> Dynamic Binding.

Some of the popular OO languages are--> C++-> Smalltalk-> Java-> Eiffel-> C#What is encapsulation ?K. INDHU8What is ENCAPSULATION ?-> Packaging an Object's variables within the protective custody of it's methods is called Encapsulation.

-> "Data Binding" is called as "Encapsulation.

What is abstraction ?K. INDHU9What is Abstraction ?-> "Data Hiding" is called as "Abstraction".

-> Often, for practical reasons, an object may wish to expose some of it's variables or hide some of it's methods.

-> Thus hiding features ( un necessary to end-user ) of an object and exposing ( only needed info. to end-user ) of an object is called as Abstraction.

-> For example- TV Set.Objects Access levels (visibility) ?K. INDHU10

What is inheritance ?K. INDHU11What is Inheritance ?-> A class inherits state & behavior from it's super-class / base-class.

-> Inheritance provides a powerful & natural mechanism for organizing and structuring software programs.

-> Inheritance also provides a mechanism for re-using already created data and methods from super-class in it's sub-classes.Inheritance pictoriallyK. INDHU12

Properties of inheritance ?K. INDHU13Properties of Inheritance->-> Each sub-class inherits state (in the form of variable declarations) from the super-class.

-> Sub-classes can add variables and methods additionally apart from the ones they inherit from the super-class.

-> Sub-classes can also override inherited methods and provide specialized implementations for those methods.

-> We are not limited to just one layer of inheritance.

-> The inheritance tree, or class hierarchy, can be as deep as needed.benefits of inheritance ?K. INDHU14Benefits of Inheritance->(1) Re-Usability:--> Subclasses provide specialized behaviors.

-> Superclass provides generalized behaviors.

-> Through the use of inheritance, programmers can re-use the code in the superclass many times.

(2) Can define Abstract Classes:--> Programmers can implement superclasses called abstract classes that define generic behaviors.What is Polymorphism ?K. INDHU15What is Polymorphism ?-> The ability to appear in many forms.

-> In object-oriented programming, Polymorphism refers to a programming language's ability to process objects differently, depending on their data type or class.

-> It is the ability to re-define methods for derived classes.

-> (eg) e-bike Acceleration system. Electronically / Mechanicallytypes of Polymorphism ?K. INDHU16

What is DYNAMiC BINDING ?K. INDHU17What is Dynamic Binding ?-> Dynamic Binding occurs when the type of variable changes, at run-time.

-> A common way for a variable to change it's type is thru assignment.

-> Bike := MountainBike is safe MountainBike := Bike is not safe.

-> A variable that starts life of the type Bike may be attached to any object that is a kind of Bike, including MountainBike. A variable that starts life of the type MountainBike can only be attached to MountainBike objects.So far we studiedK. INDHU18Object Oriented ProgrammingHAPPY LEARNING!!!