Object-Oriented Programming (OOPs)

OOPs is a concept or standard that is implemented by the programming languages. If any programming language implementing the OOPs concept in our programming language then is given more advantage like reusability, flexibility, easy to maintain, easy to read code, etc. And OOPs provides many concepts like an object, class, inheritance, polymorphism, abstraction, and encapsulation. And in this section, we will be learning about these concepts, which provides more flexibility to create an application.

OPPs Concepts:-

  • Object
  • Class
  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation

Object:- Object is a real word entity like a Fan, Pen, Car, AC, etc. And all the real-world entities that have behavior and properties is called an object.

For example:- A Pen its property color and behavior is writing.

object

Class:- A-Class is the representation of a similar type of object. And It is a logical entity.

class in java

Data Member:- Data member is the property of and object. And In java, static data members and instance data members are used to defining the object property.

Static Data Member:- Static data members define using the static keyword.

class Pen
{
static String color="blue"; // example of define static data member
static String type="gel pen";
}

Instance Data Member:- If any data member defines without using static keyword then it’s instance data member.

class Pen
{
String color="blue"; // example of define instance data member
String type="gel pen";
} 

Member Function:- In java have two types of functions static and non-static.

Static function:- In java any function defined using static keyword then it is known as a static function or static method. And non-static data member is calling without creating an instance (object) of class.

class Pen
{
public static void show() // this is static function or method
{
System.out.println("static method or function");
}
public static void main(String args[])
{
show();// call the show method
}
}

Non-Static Function:- Non-static member functions are defined without using the static keyword. And if you’re called a non-static function or method then first you have created an instance of that class.

class Pen
{
public void show() // this is static function or method
{
System.out.println("non-static method or function");
}
public static void main(String args[])
{
Pen p=new Pen();// creating and instace (object) of Pen class
p.show();// call the show method
}
}

If you have not installed java in your pc and laptop read this article.

Leave a Reply

Your email address will not be published. Required fields are marked *