+ All Categories
Home > Documents > Concepts Of Object Oriented Programming

Concepts Of Object Oriented Programming

Date post: 12-Nov-2014
Category:
Upload: anik
View: 660 times
Download: 1 times
Share this document with a friend
Description:
It will tell you all the terminologies used like variables,objects,classes etc.
13
Object Oriented Programming
Transcript
Page 1: Concepts Of Object Oriented Programming

Object Oriented Programming

Page 2: Concepts Of Object Oriented Programming

Object Oriented Programming versus Procedural Approach

Procedural Programming focuses on code acting on data thought, whereas OOPA works on the thought of data controlling access to code through objects.

Object Oriented Programming is at the heart of Java and not an option as it is in C++.

Page 3: Concepts Of Object Oriented Programming

OOPS Concepts

Abstraction Encapsulation Inheritance/Code reusability Polymorphism

Page 4: Concepts Of Object Oriented Programming

OOPS Components

Object Class

Page 5: Concepts Of Object Oriented Programming

Abstraction

The process of hiding irrelevant details of code complexity from user.

Controls the visibility of information. Focuses on the essential

characteristics of some object, relative to the perspective of the viewer.

Page 6: Concepts Of Object Oriented Programming

Encapsulation

The method of combining the data member & member functions of an object into a single unit.

Isolates the functional details of the object from outside the class.

Page 7: Concepts Of Object Oriented Programming

Inheritance/Code reusability

The process of deriving new classes from the existing ones.

Allows a class to inherit the properties from another class.

Inheritance provides the idea of reusability, because using it we can modify the existing classes by adding new features into it. The resulting class will have the combined features of both the classes.

Page 8: Concepts Of Object Oriented Programming

Polymorphism

Ability to take more than one form. The same operation may exhibit different

behavior in different instances. Behavior depends on the types of data used

in the operation. Types –

Runtime polymorphism Compile time polymorphism

Page 9: Concepts Of Object Oriented Programming

Object Basic building block for OOP. Usually correspond to real life entities. A unit of s/w comprising of:

State/Attribute – defines the properties of the object & the current values of each of these properties.

Behavior – defines the response of an object in terms of its state changes and message passing.

Identity – defines a unique name. An object stores its state in fields (variables in some

programming languages) and exposes its behavior through methods (functions in some programming languages).

Page 10: Concepts Of Object Oriented Programming

Class

a blueprint that describes the nature of something.

User-defined datatype. Used to represent a template for

several similar type of objects. Objects of the same class have the

same definition both for their state and behavior.

Page 11: Concepts Of Object Oriented Programming

Instance – creation of an object for a particular class.

Constructors – initialize an object immediately upon creation. A constructor is automatically called immediately after the object is created.

Interface - an interface is a group of related methods with empty bodies. 

Package - A package is a namespace that organizes a set of related classes and interfaces. Conceptually we can think of packages as being similar to different folders on your computer.

Page 12: Concepts Of Object Oriented Programming

Access specifiers

Java allows us to control access to classes, methods, and fields via so-called access specifiers.

Java offers four access specifiers, listed below in decreasing accessibility: Public Protected Default Private

Page 13: Concepts Of Object Oriented Programming

 Situation  publi

c  protected   default 

 private 

 Accessible to class  from same package? 

yes yes yes no

 Accessible to class  from different package? 

yes  no, unless it is a subclass  no no

Access level permitted by each specifier


Recommended