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 to perform linear search in java?

568


Can I use % with real numbers?

564


Explain the difference between extends thread vs implements runnable in java?

539


What is the collections api in java programming?

557


What is java developer skills?

517






What is the use of optional ?

568


What do you mean by global variable?

527


How can we use primitive data types as objects?

560


What is thread pool in java with example?

547


Why is serialization required?

544


How to change value in arraylist java?

506


Difference between static and dynamic class loading.

587


2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?

1840


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

545


What is an i/o filter?

569