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
Can we use string in switch case in java?
Can a main method be overloaded?
Where to store local variables?
What is the difference between logical data independence and physical data independence?
What is toarray method in java?
What is a return in java?
What does n mean in java?
What is broken and continue statement?
How do I enable java in safari?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
How many ways can we create the string object?
In the below example, what will be the output?
Is singleton class thread safe?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
What are the main uses of the super keyword?