When we can access the static data member without creating
the object what is the need of the object in java.
Answer Posted / paras bist
Static data is class level data,while objects contain
values of non static instancs varibles.
diffrent object contains diffrent values of instance
varibles ,
but all object can share same vale of static data.
Class abc{
int i;
int j;
static int x=10;
//-----some more code
}
diffrent object contain diffrent values of i&j,
but all object can share one value of x(ie 10 coz it is
static).
static data is accessed by class name and object also.
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
Will the jvm load the package twice at runtime?
Where are global variables stored?
Is the milky way in a void?
What is replacefirst in java?
Explain the selection sort algorithm and state its time complexity?
What is default exception handling in java?
Is it possible for a yielded thread to get chance for its execution again?
What type of value does sizeof return?
If an application has multiple classes in it, is it okay to have a main method in more than one class?
What is static block?
How can we find the actual size of an object on the heap?
Can we write class inside a class in java?
What is equals method in java?
What are the special characters?
Why string is called as immutable?