Why Static variable required in java?For ex,class A
{
static int a;
int b;
}
Why static is required?
Answers were Sorted based on User's Feedback
Answer / za
because it help us to declare class field asglobal variable
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / sumit pal singh
static keyword is mainly used for memory management purpose. And static variable is used for declare the common property of object.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / aswini
Without using instance of the class means no need to use the class object to call static variable insted directly use the classname to use the static variable.moreover ,only one copy of static varible avaible to use all the classes.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / vaishnavi
To answer Soumya's question, instance variables are declared at class level, but the instance variables still belong to an instance/object. But static variables belong to a class.
| Is This Answer Correct ? | 0 Yes | 0 No |
What do you know about the garbate collector?
Is array passed by reference in java?
What is an infinite loop?
What is the type of lambda expression?
What does system out println () do?
what is an anonymous class?
How to sort the elements in HashMap
Write a program to print count of empty strings in java 8?
Is java based on c?
why the wait,notify,notifyall methods are placed in object class?these are the thread concepts why these methods are placed in Object class?
2 Answers Global Logic, Satyam,
How we can generate random numbers in java?
Can two objects have same hashcode?