What is static variable and static method?
Answer Posted / abnish kumar rajput
Static variables are those variables that are declared with
static keyword of java.Static variables are declared once
into a class and are available entire class.Static variables
are common to all objects of class.Static variables can be
accessed by non-static methods.Whereas Static methods are
those which are declared with static keyword and can only be
accessed static variables.If we have Static method then we
can call it directly with class_name.And static variables
and methods both are related to class,whereas non-static
variables and methods are related to object.
| Is This Answer Correct ? | 28 Yes | 17 No |
Post New Answer View All Answers
How finally used under exception handling?
What happens if an exception is throws from an object's destructor?
Can you explain the cs option of java interpreter?
What are the different types of inheritance in java?
Is class forname reflection?
What is the purpose of the system class in java programming?
What is the purpose of javac exe?
What is private public protected in java?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?
Explain about static nested classes in java?
What are the library functions in java?
Is there any difference between synchronized methods and synchronized statements?
State one difference between a template class and class template.
What happens if an exception is throws from an object's constructor?
I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?