Can a top level class be private or protected?

Can a top level class be private or protected?

A top level class can neither be private or protected. If a top level class is declared private, the compiler will say that the “modifier private is not allowed here”. Also declaring a class private is completely useless, because nothing will have access to it. Same is the case with protected.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.