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 the difference between serializable and externalizable interface?
What is final keyword in java? Give an example.
How will you get the platform dependent values like line separator, path separator, etc., ?
Which class is used by server applications to obtain a port and listen for client requests?
Can a constructor be protected?
How do you sort an array in java?
What are the differences between heap and stack memory?
What is threaded programming and when is it used? : Java thread
Explain abstract class in java?
What is protected access modifier?
What is queue in java?
what is comparable and comparator interface?
there are N number of matchboxes numbered 1...N.each matchbox contain various number of stick.Two player can alternatevely pick some amount of stick from the higest stick containing box . The player is condidered win if there is no stick after his move.Find the final move so that the move player win. Note:In case the number of stick is equal ,pick the stick from the higest numbered box.
design an lru cache in java?
Is zero a positive integer?