Java
Java is an object-oriented language that is also platform-independent. We created methods and classes in java, to give special access to these methods and classes and to specify the accessibility and scope of the methods and classes we can use access modifiers.
Java has two types of modifiers -
1. Access Modifiers
2. Non-Access Modifiers
Access Modifiers- There are four types of access modifiers in java-
1.Public
2.Private
3.Default
4.Protected
Public- This type of access modifier can be accessible from within the class, outside the class ,within the package and outside the package.That means public type of access modifier can be accessible everywhere.
Example- We have two packages, one is 'package1' and second one is package 2'.To access a method from one package to another -
In Second package we can call above method as-
Private- This access level of modifiers can be accessed within the class.This modifier cannot be accessed from outside the class and package.
We created two class Class1 and Class2, we will create a private method and will try to access in another class-
Default- This type of access modifier can be accessed from within the package only,It cannot be accessed from outside of the package also if we do not specify any type of access modifier for a class or method then it will be considered as default.
We will create two packages- package1 and package2.
Protected- This type of access modifiers can be accessed from within the package and outside of the package by using child class, if we do not create child class then we cannot access from outside the package.
Here We will create two packages- package1 and package2.
Output will be Hello World
At Oodles ERP, we provide full-scale ERP software development services to solve complex business problems and streamline diverse business operations. Our custom ERP software development services are conducive to increasing business productivity and improving operational efficiency. For more information, contact us at [email protected].