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
Which programming language is most secure?
What is the java project architecture?
Write a program to find the whether a number is an Armstrong number or not?
Is list thread safe in java?
What is difference between path and classpath variables?
What is time complexity java?
What is the transient keyword?
Why we use methods in java?
Is singleton class immutable?
What is meant by method overriding?
How many wrapper classes are there in java?
What is length in java?
Can a constructor be made final?
What are the differences between c++ and java?
Can we modify the throws clause of the superclass method while overriding it in the subclass?