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

How do you achieve singleton?

716


What is lazy programming?

756


Why java strings are immutable in nature?

764


What is nested loop? What is dangling else condition in it?

791


What are the principle concepts of oops?

715


What is arraylist class in java?

703


What do you mean by ternary operator in java?

762


What is the difference between member variables initialization and assignment in a constructor?

864


Can we create a class inside a class in java?

732


What is a platform?

717


What is an array length?

670


What is the advantage of preparedstatement over statement?

800


Can constructor be synchronized?

723


What is backdrop?

781


What is meant by attribute?

760