+1 vote
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.

Related questions

+1 vote
asked Jun 17, 2019 in JAVA by reins.robin
0 votes
asked Jun 16, 2019 in JAVA by reins.robin
...