Hello Friends...
This question was asked to me in an interview..
Can a class be static in java?
If yes, then what is it's use and how it can be used?

Recommended Answers

All 2 Replies

See Static class declarations by InfoWord-JavaWord

“You declare a top-level class at the top level as a member of a package. Each top-level class corresponds to its own java file sporting the same name as the class name. A top-level class is by definition already top-level, so there is no point in declaring it static; it is an error to do so. The compiler will detect and report this error.
….. A nested top-level class is a member classes with a static modifier. “

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.