Skip to main content

ALL ABOUT JAVA



Object-oriented programming (OOPs) is a methodology that simplifies software development and maintenance by providing some rules.

Basic concepts of OOPs are

1.  OBJECTS: An object is an instance of a class. A class is a template or blueprint from which objects are created. So, an object is the instance(result) of a class.

2. CLASS: A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. It is a logical entity. It can't be physical.

A class in Java can contain:

Fields

Methods

Constructors

Blocks

Nested class and interface

3. INHERITANCE: 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 (Object Oriented programming systems).

The 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.

Inheritance represents the IS-A relationship which is also known as a parent-child relationship.

4. POLYMORPHISM: Polymorphism in Java is a concept by which we can perform a single action in different ways. Polymorphism is derived from 2 greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms.

There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.

5. ABSTRACTION: Abstraction is a process of hiding the implementation details and showing only functionality to the user.

6. ENCAPSULATION: Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule that is mixed with several medicines. Encapsulation in java 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 an example of a fully encapsulated class.

Comments