scope of public private protected and default in java code example
Example: access modifiers in java
Example of private access modifier:
class Demo
{
private void display()
{
System.out.println("Hello world java");
}
}
public class PrivateAccessModifierExample
{
public static void main(String[] args)
{
Demo obj = new Demo();
System.out.println(obj.display());
}
}