Java - What is OOP?
[Java]
Java is an Object-Oriented Programming (OOP) language. But what does that mean?
That means that everything in java is an object. An object is an instance of a class. A class is a blueprint (constructor) for creating objects. It defines the properties (attributes) and behaviors of the objects (methods).
For example, consider a class named Car. The Car class can have properties like color, model, and year, and methods like start(), stop(), and drive(). When you create an object of the Car class, like audi, you can set its properties and call its methods.
some advantages of Object-oriented programming are:
- OOP is faster and easier to execute
- OOP provides a clear structure for the programs
- OOP helps to keep the Java code DRY “Don’t Repeat Yourself”, and makes the code easier to maintain, modify and debug
- OOP makes it possible to create full reusable applications with less code and shorter development time
Tip: The “Don’t Repeat Yourself” (DRY) principle is about reducing the repetition of code. You should extract out the codes that are common for the application, and place them at a single place and reuse them instead of repeating it.
That was a lot of information! In the next post, we will explore the in depth the java classes and objects.
Happy hacking!