What is static variable and static method?
Answer Posted / aditya
static variables are class variables.They are globally
declared with the keyword "static".They can be intialised at
the declaration time (or) they can be initialised in static
block.They can accessed by using thier class name
(class name.static variable name).Static variables can also
be accessed by the obj name but to make the difference
between the instance variables and static variables they are
accessed using class name outside the class.Static methods
are the methods that can access only static variables,they
can access instance variables also but only through the
object of the instance variables not directly.Their values
are stored in heap memory.Any changes to the static
variables reflect in heap memory.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can we declare an interface as final?
Can we change the scope of the overridden method in the subclass?
Can you tell me range of byte?
Where are register variables stored?
What is the disadvantage of synchronization?
What is singleton pattern?
What is == mean?
What are different types of states exist for a thread?
what do you mean by classloader?
Which container method is used to cause a container to be laid out and redisplayed in java programming?
what is session in java?
What is parsing and its types?
How to sort an unsorted array in java?
What are the four pillars of java?
What is a buffer in java?