OOPs Concepts

Object-Oriented Programming (OOPs) Concept



1. Class

In Java, a Class is a collection of objects. It is a logical entity. Class is also known as blueprint for which an individual object is created. Class does not occupy any space. Following are the components which a class includes:
i. Modifiers
Modifiers are used to define the scope of the class. A class can be public, private or protected.
ii. Class name
The name of the class should begin with a letter. The name of the class and the program is always the same.
iii. Super class
Superclass is the Parent class. If any child class inherits the superclass then extends keyword is used.
iv. Body
The body of the class is surrounded by the braces {}.

2. Object

In Java, An Object is an entity which has state and behaviour. It is an instance of a class. It is a physical entity. An object contains an address which takes memory space. Objects do not contain details of data or code. Following are the things which an object contains:
i. State
It is used to represent the attributes of the object
ii. Behaviour
It is used to represent the methods of the object.
iii. Identity
It is the unique name of an object.

3. Polymorphism

If a task can be performed in many different ways then it is known as polymorphism. To achieve polymorphism in java we use method overloading(Static polymorphism) and method overriding(Dynamic polymorphism).

4. Abstraction

Abstraction means to hide internal details and showing only important functionalities. To achieve abstraction, abstract class and interface are used. And 100% abstraction is achieved from the interface.

5. Inheritance

In the concept of inheritance, one object acquires all the properties and behaviours of another object. Using this concept code can be reused. Inheritance is used to provide runtime polymorphism. Following are the important terminologies used:
i. Super Class
A superclass is the parent class or base class whose features can be inherited.
ii. Sub Class
A subclass is an intermediate class also known as a derived class, extended class or child class. It can inherit the superclass using the extend keyword.

6. Encapsulation

Encapsulation means wrapping up code into a single unit. The best example of encapsulation is the Java Class and also the Java bean. Java bean is totally encapsulated class. Encapsulation is also known as data hiding because here the data is hidden in a class.

Post a Comment

0 Comments