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 a dot notation?
Can we sort array in java?
What is consumer in java?
How to store image in arraylist in java?
What is parsing in grammar?
Which eclipse is best for java?
What happens when a thrown exception is not handled?
What is anti pattern in cyber security?
What is skeleton and stub?
Is it possible to use Semaphore/ Mutex in an Interrupt Handler?
What is the syntax and characteristics of a lambda expression? Explain
What is are packages?
Difference between overriding and overloading in java?
What is classpath?
What is the size of arraylist in java?