Java Object Oriented Programming concepts
Introduction
This tutorial will help you to
understand about Java OOP’S concepts with examples. Let’s discuss about what
are the features of Object Oriented Programming. Writing object-oriented
programs involves creating classes, creating objects from those classes, and
creating applications, which are stand-alone executable programs that use those
objects.
A class is a template, blueprint,or contract that defines what an object’s data fields and methods will be. An object is an instance of a class. You can create many instances of a class. A Java class uses variables to define data fields and methods to define actions. Additionally,a class provides methods of a special type, known as constructors, which are invoked to create a new object. A constructor can perform any action, but constructors are designed to perform initializing actions, such as initializing the data fields of objects.
Objects are made up of attributes
and methods. Attributes are the characteristics that define an object; the
values contained in attributes differentiate objects of the same class from one
another. To understand this better let’s take example of Mobile as object.
Mobile has characteristics like model, manufacturer, cost, operating system
etc. So if we create “Samsung” mobile object and “IPhone” mobile object we can
distinguish them from characteristics. The values of the attributes of an
object are also referred to as the object’s state.
There are three main features of
OOPS.
1)
Encapsulation
2)
Inheritance
3)
Polymorphism
Let’s we discuss about the about
features in details.