- Регистрация
- 1 Мар 2015
- Сообщения
- 1,481
- Баллы
- 155
Object-Oriented Programming
OOP stands for object-oriented programming. It is a programming paradigm that revolves around the object rather than function and procedure. In other words, it is an approach for developing applications that emphasize on objects. An object is a real
word entity that contains data and code. It allows binding data and code together. here objects means real world entity like car, bike, atm etc.
OOP Concepts in Java
Java follows Object-Oriented Programming (OOP), which is based on the following nine key concepts:
These are the core principles of OOP in Java:
A class in java a blueprint or template of an object from where an object is created. it doesn’t take space in the memory. It is a user-defined data type. Inside a class, we define variables, constants, functions. It is example of data binding. it is a logical entity.
Syntax
class ClassName {
// Fields (variables)
// Constructors
// Methods
}
2. Object
An Object is a real world entity that has attributes, behavior, and properties. It is referred to as an instance of the class. It contains member functions, variables that we have defined in the class. It occupies space in the memory. Different objects have
different states or attributes, and behaviors.
ClassName objectName = new ClassName();
OOP stands for object-oriented programming. It is a programming paradigm that revolves around the object rather than function and procedure. In other words, it is an approach for developing applications that emphasize on objects. An object is a real
word entity that contains data and code. It allows binding data and code together. here objects means real world entity like car, bike, atm etc.
| Procedural Programming | OOPS |
|---|---|
| programs are divided into parts called functions | Programs are divided into objects |
| Overloading is not possible | Overloading is possible |
| Inheritance is not possible | Inheritance is possible |
| Data hiding is not present | Data hiding is present |
| It follows a top-down approach | It follows a bottom-up approach |
| It focuses on the process. | It focuses on data. |
| Ex:- C, Pascal etc. | Ex:- Java, C++, Python etc. |
Java follows Object-Oriented Programming (OOP), which is based on the following nine key concepts:
- Class – A blueprint for creating objects.
- Object – An instance of a class with state and behavior.
- Encapsulation – Hiding internal details and exposing only the necessary parts.
- Polymorphism – The ability to take multiple forms (method overloading & overriding).
- Inheritance – Acquiring properties and behaviors from a parent class.
- Abstraction – Hiding implementation details and showing only essential features.
- Association – A relationship between two classes without ownership.
- Composition – A strong association where one class owns another.
These are the core principles of OOP in Java:
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
Benefits of OOP in JavaNote: Concepts and pillars are different. Java has 8 main concepts, but only 4 pillars of OOP.
- Reusability – Write once, use multiple times to reduce redundancy.
- Data Redundancy – Avoids duplication by using shared class definitions.
- Code Maintenance – Easier to update and manage code efficiently.
- Security – Encapsulation and abstraction restrict unnecessary data access.
- Easy Troubleshooting – Objects simplify debugging and modification.
- Better Design – Stable base classes reduce errors in derived classes.
A class in java a blueprint or template of an object from where an object is created. it doesn’t take space in the memory. It is a user-defined data type. Inside a class, we define variables, constants, functions. It is example of data binding. it is a logical entity.
Syntax
class ClassName {
// Fields (variables)
// Constructors
// Methods
}
2. Object
An Object is a real world entity that has attributes, behavior, and properties. It is referred to as an instance of the class. It contains member functions, variables that we have defined in the class. It occupies space in the memory. Different objects have
different states or attributes, and behaviors.
SyntaxObject is a real world entity, every object have state and behavior state tell us how the object looks like and behavior tell us what the object does.
ClassName objectName = new ClassName();
| Class | Object |
|---|---|
| It is a logical entity | It is a real-world entity |
| It is a based on concepts. | It is based on real world |
| It uses the keyword class when declared. | It uses the new keyword to create an object. |
| It does not occupy space in the memory. | It occupies space in the memory. |
| It is a data type that represents the blueprint of an |