Java is an
Object-Oriented Language. As a language that has the Object-Oriented feature,
Java supports the following fundamental concepts −
Polymorphism
Inheritance
Encapsulation
Abstraction
Classes
Objects
Objects in Java
Let us now look deep into what are objects. If we
consider the real-world, we can find many objects around us, cars, dogs,
humans, etc. All these objects have a state and a behavior.
If we consider a dog, then its state is - name,
breed, color, and the behavior is - barking, wagging the tail, running.
Software objects also have a state and a behavior.
A software object's state is stored in fields and behavior is shown via
methods.
So in software development, methods operate on the
internal state of an object and the object-to-object communication is done via
methods.
Inheritance
Inheritance
can be defined as the process where one class acquires the properties (methods
and fields) of another. With the use of inheritance the information is made
manageable in a hierarchical order.
Polymorphism
Polymorphism is the
ability of an object to take on many forms.
Encapsulation
Encapsulation in Java is a mechanism of wrapping the data
(variables) and code acting on the data (methods) together as a single unit. In
encapsulation, the variables of a class will be hidden from other classes, and
can be accessed only through the methods of their current class. Therefore, it
is also known as data hiding.
Abstraction
Abstraction is process of hiding the implementation
details and showing only the functionality.
Classes
A class is nothing but a blueprint or a template for
creating different objects which defines its properties and behaviours. Java
class objects exhibit the properties and behaviours defined by its class. A class
can contain fields and methods to describe the behaviour of an object.
No comments :
Post a Comment