What OOP'S ?
What is OOPs ?
Oop's stands for object oriented programming language. The main purpose of oops is to deal with real world entity using programming languages.
Any programming language that follow and support features like Classes, Objects, Inheritance, Polymorphism, Encapsulation, Data Binding, Message Passing and Data Abstraction is called Objects Oriented Programming Language.
The Object Oriented Programming gave a new height of programming by giving the unique way of organizing large complex programs. In Oops we organize a program using two way first is around it's Code and second is around Data.
Oops Features
1) What is class?
Class is collection of objects and it doesn't take any space on memory, class is also called blueprint | logical entity.
Syntax :
class class_name
{
--- // Data
--- // Methods
}
Example :
class Demo
{
int a = 10; String b ="Kiran";
void show()
{
System.out.print(a+" "+b);
}
}
2) What is Objects ?
Objects is instance of class, that executes the class. Once object is created, it take up space like other variable in memory.
Syntax :
class-name obj-name = new class-name()
Example :
class Demo // Class
{
? ? int a=10;
? ? String = "kiran";
? ? void show() ? ? ? // Method
? ? {
? ? ? ? System.out.print(a+" "+b);
? ? }
}
class Test // new class
{
? ? public static void main(String[] args)
? ? {
? ? ? ? Demo kiran = new Demo(); ? ?// object
? ? ? ? kiran.show();
? ? }
}
3) What is Method ?
Method is a Group / Block of code, which take input from the user. Method runs only when it called.
> Predefind - Method
pritn();
sqrt();
> Userdefind - Method
add();
display();
Example :
void display()
{
---
}
领英推荐
4) What is Inheritance ?
When a class derives from another class is called Inheritance. Inheritance is a feature or a process in which, new classes are created from the existing classes. The new class created is called “derived class” or “child class” and the existing class is known as the “base class” or “parent class”.
Once class depends on another class. Reusability - Many time used code.
An inherited class is defined by using the?extends?keyword.
Example :
class A
{
---
}
class B extends class A
{
---
}
5) What is Polymorphism ?
The word polymorphism means having many forms.
Real-life Illustration:?Polymorphism
A person at the same time can have different characteristics. Like a man at the same time is a father, a husband, an employee. So the same person possesses different behavior in different situations. This is called polymorphism.?
Example :
man(father);
man(husband);
man(employee);
6) What is Encapsulation ?
It is used to wrapping data and information under a into single unit is called encapsulation.
7) What is Abstraction ?
Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
Example :
Website - only (UI) Front End part visible from the user and all backend part hide from the user.
I hope you understood what is oops ? If you like this article Follow me for such interesting topics and you also learn with me...! #oops #oopsconcepts