What is static variable and static method?
Answer Posted / monika watts
STATIC VARIABLE: static variable is that variable that is
shared by all the objects of a class.means allocates memory
once even if we create any no of objects and even if we
create no object.
STATIC METHOD: first thing about static method is that we
can access static variables only with in static method.
and static methods can be called without the object of that
class.
let
class a
{
static void hello()
{
System.out.println("hello friend");
}
}
now we can access this method as hello() or a.hello();
without any object or with class name.
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Which java ide is used the most?
What is a dynamic array java?
What is the association?
What is java volatile?
Explain purpose of sleep() method in java?
What do you mean by jjs in java8?
What are packages in java?
What do bitwise operators do?
Explain about fail safe iterators in java?
What is difference between float and double?
What is the difference between throw and throws in java?
Why is it important to initialize a variable?
What is the difference between C++ and Java and your preferences?
Which sorting algorithm is best in java?
What is formatted output?