234k views
5 votes
What are the oop concept of java

2 Answers

6 votes

OOP stands for Object Oriented Programming. In Java, we create classes to represent different things. For instance:

public class MyClass {

public static void main(String args[]) {

Car cr = new Car();

cr.createCar("Ford", "Green", 2000);

cr.printInfo();

}

}

class Car{

private String model, color;

private int year;

void createCar(String md, String cl, int yr){

model = md;

color = cl;

year = yr;

}

void printInfo(){

System.out.println("Car Info:");

System.out.println("Model: "+model);

System.out.println("Color: "+color);

System.out.println("Year: "+year);

}

}

We create a car object derived from the Car class with whatever properties we want and then we can display the properties of our car with the printInfo() method.

This is just one example of the OOP concept of Java.

User Iwis
by
6.3k points
7 votes

Answer: OOP concepts in Java are the main ideas behind Java’s Object Oriented Programming. They are abstraction, encapsulation, inheritance, and polymorphism. Grasping them is key to understanding how Java works. Basically, Java OOP concepts let us create working methods and variables, then re-use all or part of them without compromising security.

HOPE THIS HELPED IS NOT SORRY.

User Nicolas SEPTIER
by
7.1k points