Manoj Manoj - 1 year ago 90
Java Question

Why can't we specify default access modifier for a class

I know why private and protected are illegal modifiers for a class but why is default not acceptable. I think if we don't specify any access modifier,

gets assigned. But typing it explicitly like
default class Student
gives me a syntax error

Answer Source

The default access modifier in Java can be used by just omitting any access modifier. Java 8 introduced a new default keyword used to provide a default implementation for an interface's method but, despite its confusing name and location in the method's declaration, it has nothing to do with access modifiers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download