Jun 17, 2019 in JAVA
Q: 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
Jun 17, 2019

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

0 votes
Jun 17, 2019 in JAVA
0 votes
Jun 16, 2019 in JAVA
...