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 static variable and static method?

Answer Posted / nithya

Static Variable:
A variable that can be accessed by any class.
Eg:
class Add
{
static int a; // Defaultly the value of a is 0 since,it
is declared as static.
}
class Sub
{
int A=Add.a; // the value of A is 0.
}


Static Method:
if the method is declared as Static then its variable
should be also declared as static and static method can be
accessed with the help of class name rather than object name

eg:

class Addition
{
public static void Add()
{
}
}
class Subraction
{
Addition.Add();
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is method and methodology?

1049


What is the basic concepts of OOPS?

1128


What is cr keyboard?

1139


what is the difference between Object Based Language and Object Oriented Language?

971


What are filterstreams?

1016


Tell me about your ability to work under pressure

2145


What all access modifiers are allowed for top class ?

1138


Is char a method in java?

1015


What is polymorphism java example?

936


What is the ==?

840


How can a gui component handle its own events?

1041


What are the types of methodology?

1026


Compare overloading and overriding?

953


Explain some best practices you would apply while using collection in java?

979


What is meant by data hiding/encapsulation?

1043