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
What is the default value of local and global variables?
What are different types of inner classes ?
How does thread synchronization occurs inside a monitor?
Write a program to print fibonacci series
Give any two differences between C++ and java.
What are synchronized blocks in java?
What is your platform’s default character encoding?
How does hashset work in java?
Does importing a package imports its sub-packages as well in java?
What is percentage in java?
What is space character in java?
What are the changes in java.io in java 8 ?
Difference between concurrent hashmap and hashtable and collections
What is meant by bytecode?
What is the basic concepts of OOPS?