You are on page 1of 2

NAME: SUKTEY TULJARAM ARJUN

MIS NUMBER: 112015145

5.B

There are 4 types of access protection available for packages & their implication.
- Private
- Protected
- Public
- Default

 Private:
In this variable & class are declared private, such that they can’t be access
outside the class. similarly packages with private data members also can’t
called in different package
Example code:

public class random_test


{
private static void add()
{}
private int abc;
}

 Protected:
In this variable & class are protected, such that they can be access within
the same package & the following sub-classes
Example code:

public class random_test


{
protected static void add()
{}
protected int abc;
}
 Public :
In this variable & class are public, such that they can be access from
anywhere within the package and outside the package.
Example code:

public class random_test


{
public static void add()
{}
public int abc;
}

 Default:
In this variable & class are not given any access modifiers, such that they
can be access from only same package .like protected but not from sub-
classes
Example code:

public class random_test


{
static void add()
{}
int abc;
}

You might also like