in JAVA by
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.

▼ Show 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.

JAVA
Learn More with Madanswer

Related questions

0 votes
asked Jun 17, 2019 in JAVA by reins.robin
...