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


Please Help Members By Posting Answers For Below Questions

Explain the difference between a Thread and a Process.

556


What is locale?

600


What does it mean to be immutable?

544


How to access arraylist elements in java?

486


What is backdrop?

592






Differentiate between == and equals().

594


How many types of threads are there in java?

502


What is the use of 'super' keyword inside a constructor?

559


What are the important features of Java 10 release?

508


What is arraylist class in java?

509


Can you tell me range of byte?

555


How does queue work in java?

528


How to change the priority of thread or how to set the priority of thread?

611


What is the purpose of void class?

604


What is a heavyweight component?

542