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

Why can't you declare a class as protected?

595


What is the difference between numeric and integer?

509


When do we use synchronized methods in java?

582


What is the difference between variable declaration and variable initialization?

502


Can we override data members in java?

619






Describe how to implement singleton design pattern in struts.

529


What is the use of arraylist class in java?

554


What is sorting in java?

530


What is a java string?

537


How many types of gc are there in java?

556


Can sleep() method causes another thread to sleep?

562


What is thread count in java?

543


What is java object name?

549


What is class and object in java?

549


How to call one constructor from the other constructor ?

599