Java Object Oriented Programming, Class, Object, Method, Java Inheritance, Polymorphism in Java, Java Abstraction, and Java Encapsulation.
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.
Simula is considered the first object-oriented programming, Smalltalk is considered the first truly object-oriented programming language, and The popular object-oriented languages are Java, C#, PHP, Python, C++, etc.
Java Project, Package, Class, Object, Method, Interface, and Constructor.
Project – A group of similar packages
Package – A group of similar Classes
Class – A class is a blueprint or prototype from which objects are created.
Object – An Object is called an instance of a class. Objects have states and behaviors.
Method – A Method is an action which an object is able to perform.
Constructor – A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created.
Interface – An interface is a completely “abstract class” that is used to group related methods with empty bodies.
|Man||Indian||Running||Shoes||10 inch Nike shoes|
Object-oriented Programming Principles
The four principles of object-oriented programming are Inheritance, Polymorphism, Abstraction, and Encapsulation.
Inheritance: It is the mechanism in java by which one class is allowed to inherit the features(fields and methods) of another class.
Polymorphism: Polymorphism is the ability of an object to take on many forms.
Abstraction: Abstraction is a process of hiding the implementation details and showing only functionality to the user.
Encapsulation: Encapsulation is a process of wrapping code and data together into a single unit.
Advantages and Disadvantages of OOP
Advantages of OOP
“Write once and use it multiple times” you can achieve this by using class.
Inheritance is a good feature for data redundancy. If you need the same functionality in multiple classes you can write a common class for the same functionality and inherit that class to sub-class.
3. Easy Maintenance:
It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
Using data hiding and abstraction only necessary data will be provided thus maintains the security of data.
Disadvantages of OOP
Object-Oriented Programs are much larger than other programs.
Object-Oriented Programs require a lot of work to create.
Object-Oriented Programs are slower than other programs, because of their size.