Skip to content

Latest commit

 

History

History
38 lines (17 loc) · 1.83 KB

README.md

File metadata and controls

38 lines (17 loc) · 1.83 KB

🔥 OOPS Concepts 🔥

This repository contains code examples and explanations for various Object-Oriented Programming (OOPS) concepts.

Access Modifiers

Access modifiers in OOPS determine the visibility and accessibility of class members (variables and methods). They help in controlling the access to sensitive data and functionality within a class or across different classes and packages.

The following table summarizes the different access modifiers and their visibility:

Image |

Private Access Modifier

The private access modifier restricts the visibility of a member to only within the same class. It is used to encapsulate sensitive data or implementation details that should not be accessed or modified from outside the class.

Default Access Modifier

The default access modifier (also known as package-private or package-level access) allows access to members within the same package. It is used when you want to share members between classes within the same package but restrict access from classes outside the package.

Protected Access Modifier

The protected access modifier allows access to members within the same class, same package, and subclasses (even if they are in a different package). It is used when you want to provide access to subclasses for inheritance purposes while still restricting access from classes outside the package.

Public Access Modifier

The public access modifier allows unrestricted access to members from anywhere. It is used when you want to make a member accessible to all classes and packages.


Feel free to explore the code examples in this repository to understand how access modifiers can be used in different scenarios.

Happy coding! 💛 🔥