When we can access the static data member without creating
the object what is the need of the object in java.
Answers were Sorted based on User's Feedback
Answer / avadhut rane
Object is needed to access a non static data member
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / vijay
U cant call other class method without object.static member
is common for all object.if u want set some values for
specific object then the object is necessary
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / 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 |
Answer / viswa
The question is "when we can access the static data member
with out creating object?
To access a static member of data we no need to create an
object, using class name we can access that static data member.
What is the need of the object in java?
Object is required to access the instance variables as well
as instance methods in the class.With out the object we
can't access them.
| Is This Answer Correct ? | 7 Yes | 2 No |
Answer / arun kumar maurya
there is no need to create object for static data member
because they define in class and take memory at load
time.while non static required memory dynamically so object
creation is necessary for that.object is created to
allocate the memory while in the case of static memory
already created.
| Is This Answer Correct ? | 2 Yes | 1 No |
What is lastindexof in java?
What are the disadvantages of object oriented programming?
How to make a write-only class in java?
Write a program to reverse array in place?
How the threads are synchronized?
How dead lock situation occurs in java and how you can identify it?
can we write two same methods in outer class and innerclass.
What are the restrictions imposed by a Security Manager on Applets?.
What is the size of boolean variable?
What is the reason that multiple inheritance is not possible in java??
Can private class be extended java?
What is class forname?