AMITY INSTITUTE OF INFORMATION
TECHNOLOGY
BCA
Semester-III
Object Oriented Programming Using
Java
Prof(Dr)Laxmi Ahuja
Learning Objectives
•Imparting java programming skill to students
•Knowledge of object oriented paradigm in
context of Java programming language
•Designing desktop applications using latest
Java based API
Contents to be Covered
• Definition of OOPS
• Objects
• Classes
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Definition of OOPS
• Object Oriented Programming structure
/System
• OOP is a Programming Paradigm or
Methodology
• It’s a style through which we develop programs
• Java Programming revolves around classes and
objects
• OOPS has six main Pillars
Six Main Concepts of OOPS
• Class
ALL THESE CONCEPTS ARE
• Object OF REAL WORLD
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Class
• A class describes a collection of objects with similar attributes, operations and
relationship to other objects
• A class is a blueprint or template from which objects are created
• Without class, object does not exist
• Object will follow the prototype defined by class
Class object object object
ANIMAL DOG CAT LION
BIRD BAT SPARROW PIGEON
VEHICLE SCOOTER CAR TRUCK
CLASS
• In case of Animal class - objects are Dog,
Cat, Lion
• Animal is a word to categorize objects
• Class---word, template ,blueprint,
prototype
• Class is not a real world entity.(NOT
VISIBLE IN REAL WORLD)
• Class is template to categorize the real
Here student class can consist of no of objects A,B,C and they all follow the same prototype
Student----class
A -----read() write()
B ------ read() write()
C---------- read() write()
A B C are Objects
A class in Java can contain
• Fields
• Methods
• Constructors
• Blocks
• Nested class and interface
Hierarchy of Class
Object
• Object means a real-world entity such as a
pen, chair, table, computer, watch, etc.
• Objects is the run time entities in an object
oriented system.
• An object is an instance of a class-----DOG is
an Instance of ANIMAL
• Object occupies memory-----Objects occupy
Object Consists of:
Identity: Name
State/Attribute: Color,breed,Age
Behavior: eat,run
Behavior represents the methods
Human ------Object
Name Color Height------Variables or attributes
Read()
Write()------------------------------Tasks or Methods or behaviour
performed by Human
Example
Student---object
Name Address City -------- Variables or attributes
Address
City
Read ()-------------------Task performed by student
Write()
Methods
Method is a set of codes which perform a particular task
Like in real world eat() is a task
Run() is a task
Dog is running
Dog is eating
Advantages of Methods
• Code reusability
• Code optimization
• Java programming revolves around class and object and class cannot
invoke method of another class
• To access the method of another class ,one class should create its
own object
• Class communicate with each other --- object should be created
Abstraction
• The act of representing essential features without including
the background details or explanations.
• Showing only essential parts and hiding the implementation
details.
• For Example:
If you download Android App from the playstore
We get .apk or .exe file but we never get software or functions
which are used to generate .apk or .exe file.
• All the implementation part is hidden
Cont….
• Abstraction Focus on Security
• It hides Implementation
• Inner functionality is hidden only main part is visible
• For Example: Car----Color , Break,starring(visible)(Machinery
hidden)
• In java Abstraction can be achieved by two ways:
• By using Abstract Class
• By using Interface
Abstraction
Abstraction is a process of hiding the implementation details and
showing only functionality to the user.
Example:
sending SMS where you type the text and send the message.
Internal processing about the message delivery is not known
Encapsulation
Encapsulation is the mechanism that binds together code and the
data it manipulates , and keeps both safe from outside interference
and misuse.
Encapsulation in Java is a process of wrapping code and data
together into a single unit.
Example: a capsule which is mixed of several medicines.
• Data Hiding
• For Example : Car Engine(Hidden not visible to user)
• Binding
02/20/2025
variables and methods under single unit 17
Inheritance
Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviors of a parent object.
We can reuse methods and fields of the parent class. Moreover, you can add
new methods and fields in your current class (derived class) also.
Animal
.
Mammal Reptile
Dog
Cat
18
The concept of inheritance provides the idea of reusability
Polymorphism
• Polymorphism in Java is a concept by which we can perform a single action in
different ways. So polymorphism means many forms.
• Performing the task in different ways .Here task is a method
• Invoking the methods in different ways.
• One Interface many Methods
• Many Forms
• For example:
Program of adding two numbers
Add()
Add(int a ,int b)
Here both methods perform same task but implementation is different
Implementing the task in different ways
Shape
Draw ()
Circle object Box object Triangle object
Draw(circle) Draw(box) Draw(triangle)
Here Shape can be circle , Box, Triangle
Shape can be of any type but Implementing this task is different
20
Continue…..
In java we create methods and methods create different forms
Water------Solid,liquid,gas(Forms of Water)
Polymorphism can be obtained in java by Methods
Methods have different Forms
There are two types of polymorphism
• Compile Time also known as Static Polymorphism(Method Overloading)
• Compile time handled by compiler
• Run Time also Known as Dynamic Polymorphism(Method Overriding)
• Run Time handled by JVM
INTRODUCTION TO JAVA
INTRODUCTION
• Java is most popular and powerful Object Oriented programming language
• Developed by James Gosling and his Team in 1991 at sun Microsystem ,Inc but in 1995
first version of Java was released as java 1.0
• Java is a breed of coffee
• Earlier Java was known as “OAK” ,Later it renamed with JAVA
• In 2010 Java was acquired by Oracle Company
• JAVA is known as Platform Independent language or “Write once run anywhere”(WORA)
• JAVA is Everywhere
• It helps to design Applications and Applets
JAVA Flavors
• JAVA SE(Core Java)
• JDK EE(Advance Java)
• JDK ME(Micro Edition for Mobiles)
• MANY MORE…..
THANK YOU