8.basic Concepts of OOPS
8.basic Concepts of OOPS
8.basic Concepts of OOPS
USING JAVA
MODULE 1
BASIC OBJECT ORIENTED CONCEPTS
Basic Object Oriented Concepts
Object-Oriented Programming (OOP) is the term used to describe a programming
approach based on objects and classes.
The Object –Oriented Paradigm allows us to organise software as a collection of objects
Example:
Let’s take Student as a class. James is an instance / object of the class
Student
Object has a physical existence while a class is just a logical definition .
Another Example-Class
Abstraction
Abstraction means displaying only essential information and hiding the internal
details.
● It is a process of generalizing things at design level.
● Data abstraction refers to providing only essential information about the data
to the outside world, hiding the background details or implementation.
● Consider a real-life example of a man driving a car. The man only knows that
pressing the accelerators will increase the speed of the car or applying brakes
will stop the car.● All about showing necessary details.
Encapsulation
The wrapping up of data(variables) and functions (methods) that operates on the data,
into a single unit (called class) is known as encapsulation.
● It is also called "information hiding“, hides the internal representation, or state, of an
object from the outside through access modifies (Private / Public).
● Hiding unnecessary details, at implementation level.
Protection of data from accidental corruption, by means of access specifiers (Private /
Public), it provides security.
• Flexibility and extensibility of the code and reduction in complexity
• Encapsulation of a class can hide the internal details of how an object does something
• Encapsulation protects abstraction
Inheritance
The capability of a class to derive properties and characteristics from another class is
called Inheritance.
Inheritance is the process by which objects of one class acquired the properties of
Super class.
Derived Class : The class that inherits properties from another class is called Subclass or
Derived Class.
Inheritance
Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create
a new class and there is already a class that includes some of the code that we want, we
can derive our new class from the existing class. By doing this, we are reusing the fields
and methods of the existing class.
Polymorphism
The word polymorphism means having many forms.
● Refers to a programming language's ability to process objects differently depending on
their data type or class
● An operation may exhibit different behaviors in different instances. The behavior
depends upon the types of data used in the operation.
● Ability for objects of different classes related by inheritance to respond differently to
the same member function call
Static polymorphism: the binding between the method call an the method body
happens at the time of compilation and, this binding is known as static binding or early
binding
● Runtime polymorphism or Dynamic Method Dispatch is a process in which a call to an
overridden method is resolved at runtime.
● Dynamic binding happens when all information needed for a function call cannot be
determined at compile-time(Dynamic Binding or Late Binding)
● In the example, same rotation of steering wheel causes, different mechanical