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

What's a method in programming?

774


What is the difference between jdk, jre, and jvm?

818


How many decimal places is a double?

749


What is the importance of static variable?

820


What is the main advantage of passing argument by reference?

736


What are the legal operands of the instanceof operator?

804


What do you understand by synchronization?

811


Can we override private methods?

785


What is remote method invocation (rmi)?

832


What is byte code and why is it important to java’s use for internet programming?

840


What is rmi and steps involved in developing an rmi object?

821


Tell me a few examples of final classes defined in Java API?

796


What is an object class?

788


Can we print null in java?

803


How do you trim a space in java?

740