What is static variable and static method?
Answer Posted / viral
class A
{ static int a;
}
class StaticDemo
{ public static void main(String args[])
{ A obj1 = new A();
A obj2 = new A();
}
}
In such a case, objects obj1 and obj2 will not have
different copies of variable a. Both objects will refer to
the same "a". In simpler words, copy of "a" is not created.
If "a" was not static, then obj1 and obj2 would hold
different copies of "a".
| Is This Answer Correct ? | 14 Yes | 0 No |
Post New Answer View All Answers
What is jpa specification?
Are generics important java?
what is object-oriented programming in java?
Can an arraylist be empty?
What are the benefits of immutable objects?
What is the importance of main method in Java?
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?????
What is bubble sorting in java?
Explain the transient field modifier?
What is the difference between && and & in java?
Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.
What is meant by oops concept in java?
What are different types of states exist for a thread?
What are the restrictions that are applied to the java static methods?
Is list thread safe in java?