Unit1 Introduction
Unit1 Introduction
Programming
What is object-oriented
programming?
• Object-oriented programming (OOP) is a
computer programming model that
organizes software design around data, or
objects, rather than functions and logic. An
object can be defined as a data field that has
unique attributes and behavior
Overview of OOP
• The object-oriented programming (called
"OOP") is a programming paradigm in which
the programs are organized as sets of objects.
Each object represents an instance of a given
class, all the classes being members of a class
hierarchy unified by inheritance relationships.
Therefore, objects are used by the OOP.
• Each object is an instance of a given class.
• The classes are linked between themselves by
the inheritance relationships.
Object-Oriented Programming
Paradigm
• The major motivating factor in the invention of object-oriented
approach is to remove some of the flaws encountered in the
procedural approach.
• OOP treats data as a critical element in the program development
and does not allow it to flow freely around the systems.
• It ties data more closely to the functions that operate on it, and
protects it from accidental modification from outside functions.
• OOP allows decomposition of a problem into a number of entities
called objects and then builds data and functions around these objects.
• The data of an object can be accessed only by the function associated
with that object.
• However, functions of one object can access the the functions of other
objects.
Object Oriented
Programming
The Object-Oriented Paradigm
Software Engineering
Department
Object Oriented
Programming
Features of Object-Oriented Programming
• Objects
• Classes
• Data Abstraction
• Data Encapsulation
• Inheritance
• Polymorphism
• Message passing
Software Engineering
Department
Object Oriented
Programming
Classes
• User defined data types on which objects are
created.
• Objects with similar properties and methods are
grouped together to form a Class.
• For example, mango,
apple and orange are
members of class fruit.
Software Engineering
Department
Class is defined by three elements.
1.a unique class name
2.data members or attributes
3.methods
Class Student
{
int rollno;
char name[10];
Void getdata()
{
}
Void display()
{
}
Object Oriented
Programming
Objects
• Run time entities that may represent a person, place,
bank account or any item.
• Each object contains data, and code to manipulate
the data.
• Data represents the attributes of that object and
functions represents the behaviour of that object
Student s;
s.rollno=101//state
s.name=“ram”//state or attribute
s.getdata();//behaviour
Software Engineering
Department
Object Oriented
Programming
Objects Contd.
Software Engineering
Department
Object Oriented
Programming
Data Abstraction
Software Engineering
Department
Object Oriented
Programming
Data Encapsulation
Software Engineering
Department
Object Oriented
Programming
Example of Inheritance
Automobile
Software Engineering
Department
Types of Inheritance
Object Oriented
Programming
Types of Inheritance
• Single level
• Multi level
• Multiple
• Hierarchical
• Hybrid
Software Engineering
Department
Polymorphism
• Ability to take more than one form.
• Two types of Polymorphism
• compile Time Polymorphism
– Method Overloading
• Runtime Polymorphism
– Method Overriding
Introduction
Java is a Programming language and a Platform.
• Mobile Applications
• In 1992, the Green Project was spun off and its interest directed
toward building highly interactive devices for the cable TV
industry. This failed to materialize.
• In 1994, the focus of the original team was re-targeted, this time
to the use of Internet technology. A small web browser called
HotJava was written.
• Oak was renamed to Java after learning that Oak had already
been trademarked.
• In 1995, Java was first publicly released.
JRE
JRE is an acronym for Java Runtime Environment.
It is the implementation of JVM and used to provide runtime
environment.
It contains set of libraries and other files that JVM uses at
runtime.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Understanding JVM
JVM (Java Virtual Machine) is an abstract machine.
It is a specification that provides runtime environment in
which java byte code can be executed.
JVMs are available for many hardware and software
platforms.