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

Does java trim remove newline?

930


How many types of memory areas are allocated by JVM in java?

1026


What is treeset and treemap in java?

1017


What is the use of string and stringbuffer?

940


Can we cast any other type to boolean type with type casting?

899


What are the advantages of unicode?

978


What are some alternatives to inheritance?

1053


How to store image in arraylist in java?

927


When should I use singleton pattern?

983


Explain heap sort?

1052


Why we cannot override static method?

997


What is a boolean output?

920


What is the use of arraylist in java?

1036


How do you remove duplicates in java?

961


Can we convert list to set in java?

926