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
What is method and methodology?
What is the basic concepts of OOPS?
What is cr keyboard?
what is the difference between Object Based Language and Object Oriented Language?
What are filterstreams?
Tell me about your ability to work under pressure
What all access modifiers are allowed for top class ?
Is char a method in java?
What is polymorphism java example?
What is the ==?
How can a gui component handle its own events?
What are the types of methodology?
Compare overloading and overriding?
Explain some best practices you would apply while using collection in java?
What is meant by data hiding/encapsulation?