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
Do you need to import math in java?
What does g mean in regex?
What super () does in java?
What is static keyword?
Can you give names of Container classes?
What technique can be employed to compare two strings?
What are different data types?
What are implicit objects in java?
What is the latest version of java?
What are the concepts of 'OOPS'?
How does the java compiler work?
how to open and edit XML file in Weblogic???
What is variable and rules of variable?
What is jagged array in java?
What do heavy weight components mean in java programming?