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 are the three parts of a lambda expression? What is the type of lambda expression?

1083


Why is a singleton bad?

1003


Is java 9 released?

1065


Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?

1057


What is internal iteration in java se 8?

1255


What do you mean by checked exceptions?

997


Explain super keyword in java.

1076


What is this keyword in java?

1081


How to perform merge sort in java?

1118


What is the purpose of using javap?

1154


Which access specifier can be used with class ?

1045


What is java util collection?

1156


What is nextint java?

1128


What are the differences between abstract class and interface?

1158


What is the difference between the paint() and repaint() methods in java programming?

1236