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
Is java se free?
What are different data types?
What is a conditional statement explain with example?
What are keywords give examples?
How many bytes is a string?
How transient variable is different from volatile variable?
Can we restart a dead thread in java?
What is the simpletimezone class in java programming?
What is %d in printf?
Can one thread block the other thread?
difference between byte stream class and character stream class?
Highest level event class of the event-delegation model?
What is meant by oops concept in java?
What is parsing in grammar?
How to calculate the length of a singly linked list in java?