Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is difference between static method and static
variable?

Answers were Sorted based on User's Feedback



What is difference between static method and static variable?..

Answer / kusum

if a variable is declared static only single copy is
visible to all instances of class.if a method is declared
as static it is executed first as how main method is
executed in java

Is This Answer Correct ?    22 Yes 9 No

What is difference between static method and static variable?..

Answer / priyabrata patro

first let us see what is method and variable.
method is nothing but a functionality which is collection of statement.But variable is a container which contains data.
second is what is the usage of static keyword.
By using static keyword you can save memory , i mean if you declare one non static member than while creating object it will occupie memory but once you have declared one member as a static , it will not allocate memory number times rather than once.
ok , now let us find out about our question.
static mehod contains statements and where exactly you can use static variable.And it can be invoked by any methods only.
And static variable contains data which can be modified by any methods.And it can be used by method and also other variable. And one main thing about static variable is you can declare a static member as local variable.

Sorry , i could not be able to declare about static . ok , if you want to know more than contact me in this mail id priyabrata.try@gmail.com

Is This Answer Correct ?    13 Yes 1 No

What is difference between static method and static variable?..

Answer / kalandi sahoo

static variable is uniqe copy of in memory.that is every
object is share the static variable.

Is This Answer Correct ?    9 Yes 0 No

What is difference between static method and static variable?..

Answer / jimm

static variable can be used by static as well as non-static
method.
and static method only uses static variable

Is This Answer Correct ?    12 Yes 8 No

What is difference between static method and static variable?..

Answer / archana

if we declare a variable as static then it has only one copy
for all classes. if a method is declared as static without
using object we can call it.

Is This Answer Correct ?    11 Yes 9 No

What is difference between static method and static variable?..

Answer / joh-b tanzania

The static keyword denotes that a member variable, or method, can be accessed without requiring an instantiation of the class to which it belongs.

In simple terms, it means that you can call a method, even if you've never created the object to which it belongs! Every time you run a stand-alone application (which requires a static main method), the virtual machine can call the main method without creating a new application object. Of course, unless the application's methods are all static, you will need to create an instance of it at some point.

With regard to member variables, it means that they can be read from, and written to, without creating an object. You may have noticed that many classes create constants that can be read, without creating an object.

static final int VERSION = 2;

Static member variables are shared by all instances of the class to which they belong. When writing classes, this can be a handy feature. Consider the following example, where a counter is used to track how many myObject instantiations have taken place.

public class myObject
{
static int objectCount = 0;

public myObject()
{
objectCount++;
}

public String toString()
{
return new String ("There are " + objectCount + " objects");
}
}

Is This Answer Correct ?    3 Yes 1 No

What is difference between static method and static variable?..

Answer / n.siddardh

static variable copy is available to every object in the
memory if we change one value in an object there no effect
inother objects,and if we declare a method as static that
will be executed by the JVM like main method
The execution of JVM
1.static block
2.static methods
3.Instance methods

Is This Answer Correct ?    7 Yes 12 No

Post New Answer

More Core Java Interview Questions

Do we have pointers in java?

0 Answers  


What is the structure of java?

0 Answers  


does core java and j2se both are same?

5 Answers  


How do you reverse sort in java?

0 Answers  


What is the difference between serial and throughput garbage collector?

0 Answers  


What do you understand by weak reference?

0 Answers  


Write a java program to count the number of words present in a string?

0 Answers  


What is the full meaning of java?

0 Answers  


How does serialization work

3 Answers   Ordain Solutions,


Why does java have two ways to create child threads?

0 Answers  


what is d difference between deep cloning and shallow cloning in core java?

3 Answers   Satyam,


What is the buffer limit?

0 Answers  


Categories