What is static variable and static method?
Answer Posted / monika watts
STATIC VARIABLE: static variable is that variable that is
shared by all the objects of a class.means allocates memory
once even if we create any no of objects and even if we
create no object.
STATIC METHOD: first thing about static method is that we
can access static variables only with in static method.
and static methods can be called without the object of that
class.
let
class a
{
static void hello()
{
System.out.println("hello friend");
}
}
now we can access this method as hello() or a.hello();
without any object or with class name.
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Is there a case when finally will not execute?
Can we override a variable in java?
What is runtime locatable code?
Explain the use of javap tool.
Explain the difference between comparator and comparable in java?
Explain java coding standards for variables ?
Can I extend singleton class in java?
What is Java Annotations?
What is general methodology?
What Is Composition?
What is gc()?
Is string passed by reference in java?
What is supplier in java?
What is a final class ?
What is classes in java?