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

Can we override private methods?

1051


Is java platform independent?

981


What are the different ways of implementing thread? Which one is more advantageous?

986


How do you calculate square roots?

1168


Where are global variables stored?

958


What are different types of encoding?

1081


how would you implement a thread pool? : Java thread

923


What is the difference between a window and a frame in java programming?

1139


Which oo concept is achieved by using overloading and overriding?

1014


What is the arraylist in java?

1058


What is a condition in programming?

1013


What kind of variables can a class consist?

1060


How do you compare values in java?

1030


What are inbuilt functions in java?

1090


Why webdriver is an interface?

1059