why top level class could not be static

Answer Posted / sanket mehta

static keyword is meant for providing memory and executing logic without creating Objects, a class does not have a value logic directly, so the static keyword is not allowed for outer class

If you declare the outer class as static, it will not allow to compile giving : Illegal modifier for the class classname; only public, abstract & final are permitted

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you remove an object from an arraylist in java?

462


What are the characteristics of Final,Finally and Finalize keywords.

701


What is a prefix function.write down a code to compute prefix function.

538


java program with complete 4 oops concepts implemented example

2726


Can java inner class be static?

557






What is the difference between sleep and wait in java?

511


What is an example of a constant variable?

527


Explain a situation where finally block will not be executed?

570


Explain about anonymous inner classes ?

578


What is a method type?

530


Why javac is not recognized?

517


What is meant by string is immutable?

515


Is string is a data type?

568


What is difference between this and super keyword?

512


What is reflexive association?

1005