What are the limitations for static method?

Answer Posted / puneet

Static in context of java is something which is executed at
the time when the class is loaded by either bootstrap loader
or another loader into memory.These are basically for
initializations of the variables which wil be used by all
the instance variables.Say we need ot restrict how many
objects whill be created of the class store the no.of
objects created in a static variable and everytime the
object is called thestatic variable is incremented and as
soon as it reaches a limit restrict it by some logic.

The static methods can be called by the object refrence of
the class or the class name, they cannot use instance
variables or instance methods, they are the part of the
class and not instance, the static variables are stored in
registers and remain in the memory as long as the clas in
unloaded.

Is This Answer Correct ?    10 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List the interfaces which extends collection interface?

736


What is meant by JVM? Is JVM platform independent or not?

833


What is the difference between length and size in java?

715


Mention some features of java?

739


What are the main uses of the super keyword?

755


Explain the differences between abstraction and encapsulation?

784


What are the different types of sorting in java?

739


How to create an interface?

829


What is json parser in java?

814


What is difference between == and === in js?

792


What is %02d?

778


Is java code slower than native code?

771


What is the meaning of 3 dots in java?

886


Can you run java program without main method?

800


how does the run() method in runnable work? : Java thread

700