Explain the purpose of static methods and static variables in Java.

When there is a requirement to share a method or a variable between multiple objects of a class instead
of creating separate copies for each object, we use static keyword to make a method or variable shared for all objects.

Static variable: Static variables are also known as Class variables.

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.