What is OOPs concept?

Nitin Kushwaha

Total Post:16

Points:112

Posted by  Nitin Kushwaha
 148  View(s)
Ratings:
Rate this:
Please describe...
  1. Re: What is OOPs concept?

    OOPs (Object-Oriented Programming) Concept;-

    It is a method that can be used to create a program by using classes and objects.

    They provide some concepts such as:-

    • Objects.
    • Classes.
    • Inheritance.
    • Polymorphism.
    • Abstraction.
    • Encapsulation.

    Object-

    • Any entity that has identity and behavior.
    • It is an instance of a class.
    • It may be physical or logical.
    • Example-chair, pen, fan, desk, etc.

    How to create an Object:-

    An object is created from classes, in Java.

    Classname object=new classname();

    Example-

    Create an object and print value of i.

    Class Student
    

    {

    int i=21;

    public static void main(String args[])

    {

    Student s = new Student();

    System.out.println(s.i);

    }

    }

    Output-

    21

    Class;-

    • It is a collection of an object.
    • It is a logical entity.
    • It does not contain any memory space.
    • In other words, a class is a blueprint of an object.

    Create a Class-

    public class student
    

     {

      int m = 22;

    }

    Inheritance;-

    • When one class is derived from another class.
    • In other words when one object(child) holds all the properties of another object(parent) is called inheritance.
    • Extend keyword is used to derive the class properties.

    Polymorphism;-

    • If one thing can be represented in different ways is called a Polymorphism.
    • We can use Method overloading and Method overriding to achieve polymorphism, in java.
    • For example an area of Circle, Rectangle, Square, etc.

    Abstraction 

    • It is a process of hiding details and shows essential details only to the users.
    • Abstraction can be achieved either abstract classes or interfaces.
    • abstract keyword is used.

    Encapsulation;-

    • It is a way to binding code into a single unit.
    • Every Java class is an example of encapsulation.
    • In encapsulation, we can use two methods-
    • Setter used for, set the value.
    • Getter used for, get the value


Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.