Java - What is OOP?
OOP stands for Object-Oriented Programming.
Procedural programming is about writing procedures or methods that perform operations on the data, while object-oriented programming is about creating objects that contain both data and methods.
Object-oriented programming has several advantages over procedural programming:
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
Java - What are Classes and Objects?
Classes and objects are the two main aspects of object-oriented programming.
Look at the following illustration to see the difference between class and objects:
class
Fruit
objects
Apple
Banana
Mango
Another example:
class
Car
objects
Volvo
Audi
Toyota
inheritance inheritance
Inheritance in Java is a core OOP concept that allows a class to acquire properties and behaviors from another class. It helps in creating a new class from an existing class, promoting code reusability and better organization.
A subclass can reuse the fields and methods of the parent class without rewriting the code
A subclass can add its own fields and methods or modify existing ones to extend functionality.
Top comments (0)