Lecture 2
Lecture 2
2
Content
(Unit I)
Principles of Object-Oriented Programming
Chapter 1.1:
Lecture1.1.2-
1. OOPS Concept
2. C++ versus Java
3. JDK
3
Objectives/Outcomes
4
Programming languages
6
Object Oriented Programming Contd.
.
• Procedural languages such as C employ this model to considerable success
• To manage increasing complexity, the second approach, called object-oriented
programming, was conceived. Object-oriented programming organizes a program
around its data (that is, objects) and a set of well-defined interfaces to that data. An
object-oriented program can be characterized as data controlling access to code.
7
Abstraction
• An essential element of object-oriented programming is abstraction.
• Humans manage complexity through abstraction. For example, people do not think
of a car as a set of tens of thousands of individual parts. They think of it as a well-
defined object with its own unique behavior.
• Data Abstraction is the property by virtue of which only the essential details are
displayed to the user.
• In java, abstraction is achieved by interfaces and abstract classes. We can achieve
100% abstraction using interfaces.
8
Encapsulation
• Encapsulation is the mechanism that binds together code and the data it manipulates,
and keeps both safe from outside interference and misuse.
• One way to think about encapsulation is as a protective wrapper that prevents the
code and data from being arbitrarily accessed by other code defined outside the
wrapper.
Fig 2: Encapsulation[2]
9
Encapsulation Example
Fig 4: Inheritance[4]
11
Inheritance Example
12
Polymorphism
• Polymorphism (from Greek, meaning “many forms”) is a feature that allows one
interface to be used for a general class of actions.
• Polymorphism in Java is a concept by which we can perform a single action in
different ways.
• There are two types of polymorphism in Java: compile-time polymorphism and
runtime polymorphism. We can perform polymorphism in java by method
overloading and method overriding.
13
Polymorphism Example
14
C++ versus Java
16
JDK (Java Development Kit)
17
JDK (Java Development Kit)
18
JDK (Java Development Kit)
19
JDK (Java Development Kit)
20
Permanent Path of JDK in Windows
21
Setting Environment Variables
22
Setting Environment Variables
23
Setting Environment Variables
24
Temporary path of JDK in Windows
25
References
• Fig 1: https://www.digimat.in/nptel/courses/video/106105191/L01.html
• Fig 2: https://www.digimat.in/nptel/courses/video/106105191/L01.html
• Fig 3: https://www.digimat.in/nptel/courses/video/106105191/L01.html
• Fig 4: https://www.javatpoint.com/inheritance-in-java
• Fig 5: https://www.digimat.in/nptel/courses/video/106105191/L01.html
• Fig 6:https://www.digimat.in/nptel/courses/video/106105191/L01.html
• Fig 7: https://www.digimat.in/nptel/courses/video/106105191/L01.html
26
References
• https://www.tutorialspoint.com/java/java_abstraction.htm
• https://www.tutorialspoint.com/java/java_encapsulation.htm
• https://www.tutorialspoint.com/java/java_inheritance.htm
• https://www.tutorialspoint.com/java/java_polymorphism.htm
• https://www.javatpoint.com/how-to-set-path-in-java
• https://www.java.com/en/download/help/path.xml
27
THANK YOU