in JAVA by
What all access modifiers are allowed for top class ?

For top level class only two access modifiers are allowed. public and default. If a class is declared as

public it is visible everywhere.

If a class is declared default it is visible only in same package.

If we try to give private and protected as access modifier to class we get the below compilation error.

Illegal Modifier for the class only public,abstract and final are permitted.

1 Answer

0 votes
by

For top level class only two access modifiers are allowed. public and default. If a class is declared as

public it is visible everywhere.

If a class is declared default it is visible only in same package.

If we try to give private and protected as access modifier to class we get the below compilation error.

Illegal Modifier for the class only public,abstract and final are permitted.

...