You are on page 1of 10

JAVA PROGRAMMING

Code : 05201201

MCA [ Semester-I ]
Faculty of IT & Compute Science
PARUL UNIVERSITY
Introduction to Java
UNIT-1 [Datatypes, Operators, Statements]

Lecture – 2

• OOP Approach
• Concepts of OOP - classes and objects, abstraction and
encapsulation,inheritance, polymorphism, Dynamic Binding.
• Comparison of OO and procedure oriented approaches
Basic Concept of OO Approach
• Feature of OO paradigm are:
• Focus on Data rather than procedure.
• Programs are divided into objects.
• Designed data structures to characterize the objects.
e.g.: Classes
• Data and related methods are tied together in the class.
• Data is hidden and can’t be accesses by external
functions.
• Objects can communicate via methods.
• New data and methods can be easily added whenever
necessary.
• Follows bottom-up approach in program design.
Comparison of OO and procedure oriented
approaches:
Procedure Oriented Object Oriented
Programming Programming
Divided Into In POP, program is divided into In OOP, program is
small parts called functions. divided into parts called
objects.
Importance In POP, Importance is not given In OOP, Importance is
to data but to functions as well given to the data rather
as sequence of actions to be than procedures or
done. functions because it
works as a real world.

Approach POP follows Top Down approach. OOP follows Bottom Up


approach.

Access POP does not have any access OOP has access
specifier. specifiers named Public,
Specifiers
Private, Protected, etc.
Data Moving In POP, Data can move freely In OOP, objects can move and
from function to function in the communicate with each other
system. through member functions.

Expansion To add new data and function OOP provides an easy way to
in POP is not so easy. add new data and function.

Data Access In POP, Most function uses In OOP, data can not move
Global data for sharing that can easily from function to
be accessed freely from function, it can be kept public
function to function in the or private so we can control the
system. access of data.

Data Hiding POP does not have any proper OOP provides Data Hiding so
way for hiding data so it is less provides more security.
secure.

Overloading In POP, Overloading is not In OOP, overloading is possible


possible. in the form of Function
Overloading and Operator
Overloading.

Examples Example of POP are : C, VB, Example of OOP are : C++,


FORTRAN, Pascal. JAVA, VB.NET, C#.NET.
Concepts of OOP:
There are some basic concepts of object
oriented programming as follows:
• 1. Object
• 2. Class
• 3. Data abstraction
• 4. Data encapsulation
• 5. Inheritance
• 6. Polymorphism
• 7. Dynamic binding
Objects
• Object = Data + Methods to operate the data.
• Object can interact without having to identify the
details of each other’s data or code.
• Objects can be a “Place”, “Person” or “Things”.
• Objects are important runtime entities in object
oriented method to identify the attributes. E.g. CAR
Classes
• Class = set of common attribute and common operations
of an object
• Attributes = properties  defined by Data
Members(instance variables).
• Operation = behavior or activities  defined by Methods.

• Class is a user defined data type which includes


complete set of data and code of an object.
• The objects are variable of type class.
• Once the class has been defined, we can make any
number of objects belonging to that class.
• Main features of class are Reusability and ability to
create objects when needed.
Classes [ cont…]
• As we learned that, the classification of objects into
various classes is based on its properties (States) and
behavior (methods).

• In above example, we will create an objects MH-01 1234


belonging to the class car.
Abstraction

• Abstraction = the act of representing important description


without including the background details or difficult
explanations.

• Classes use the concept of abstraction and summarize all


the important properties of the objects that are to be
created.
• Write once. Forget forever.

• So, the Classes are also known as Abstract Data Type


(ADT).

You might also like