AKASH CHOWDHURY - Oops
AKASH CHOWDHURY - Oops
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. OOP
focuses on the objects that developers want to manipulate rather than the logic required to manipulate them.
A class is a user defined layout or blueprint of an object that describes what a specific kind of object will look like. A class is
a blueprint that defines the variables and the method common to all objects of a certain kind. It helps us to bind data and
methods together making code reusable unlike procedure language.
Syntax:
//code}
OBJECT
An entity that has state and behavior is known as an object. An object is an instance of a class. An object does not have a
name in essence but it is referred to by a reference variable which has a name
An object has three characteristics:
• State: represents the data (value) of an object.
• Behavior: represents the behavior (functionality) of an object .
• Identity: An object identity is typically implemented via a unique ID. The value of the ID is not visible to the external
user. However, it is used internally by the JVM to identify each object uniquely.
• Private: We can access the private modifier only within the same class and not from outside the class.
• Default: We can access the default modifier only within the same package and not from outside the package. And also, if
we do not specify any access modifier it will automatically consider it as default.
• Protected: We can access the protected modifier within the same package and also from outside the package with the help
of the child class.
Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an
important part of OOPs he idea behind inheritance in Java is that you can create new classes that are built upon existing
classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can
add new methods and fields in your current class also.
// code
}
POLYMORPHISM
Polymorphism is considered one of the important features of Object-Oriented Programming. Polymorphism allows us to
perform a single action in different ways. In other words, polymorphism allows you to define one interface and have
multiple implementations. The word “poly” means many and “morphs” means forms, So it means many forms.
There are two types of polymorphism in java :
1. Compile-Time Polymorphism :It is also known as static polymorphism. This type of polymorphism is achieved by
function overloading or operator overloading.
2. Runtime Polymorphism : It is also known as Dynamic Method Dispatch.
It is a process in which a function call to the overridden method is resolved
at Runtime. This type of polymorphism is achieved by Method Overriding.
ABSTRACTION
Data Abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring the
irrelevant details. The properties and behaviors of an object differentiate it from other objects of similar type and also help
in classifying/grouping the objects. Abstraction can be achieved with either abstract classes or interfaces.
The abstract keyword is a non-access modifier, used for classes and methods:
1. Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another
class).
2. Abstract method: can only be used in an abstract class, and
it does not have a body. The body is provided by the subclass
(inherited from).
ENCAPSULATION
Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule which is
mixed of several medicines. We can create a fully encapsulated class in Java by making all the data members of the class
private. Now we can use setter and getter methods to set and get the data in it. The Java Bean class is the example of a fully
encapsulated class.
REFERENCES
Information for the project has been taken from the following website :
• www.google.com
• www.wikipedia.com
• www.GeekforGeeks.com