Menu
Topics Index
...
`

Protection - Java Example Program


Protection
package packageOne;


class Protection
{
    int i = 5; // default access specifier
    private final int pri_i = 10; //Accessible within the class
    protected int pro_i = 15;
    public int pub_i = 20;

}
OUTPUT

DESCRIPTION

In the above program we have created a class named Protection in the package packageOne and declared variable i, pri_i, pro_i, pub_i using the access specifiers default, private, protected and public.

© meritcampus 2019

All Rights Reserved.

Open In App